forked from jasder/antlr
Fixed demo compilation for Visual Studio 2013.
This commit is contained in:
parent
e2d545fb2e
commit
e6ebc5c36b
|
@ -96,7 +96,8 @@
|
|||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -113,7 +114,8 @@
|
|||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -132,7 +134,8 @@
|
|||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -153,7 +156,8 @@
|
|||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -173,7 +177,6 @@
|
|||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\runtime\src\antlrcpp-Prefix.h" />
|
||||
<ClInclude Include="..\..\generated\TLexer.h" />
|
||||
<ClInclude Include="..\..\generated\TParser.h" />
|
||||
<ClInclude Include="..\..\generated\TParserBaseListener.h" />
|
||||
|
|
|
@ -59,8 +59,5 @@
|
|||
<ClInclude Include="..\..\generated\TParserVisitor.h">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\runtime\src\antlrcpp-Prefix.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
//
|
||||
// main.cpp
|
||||
// antlr4-cpp-demo
|
||||
//
|
||||
|
@ -7,28 +7,27 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "ANTLRInputStream.h"
|
||||
#include "CommonTokenStream.h"
|
||||
#include "antlr4-runtime.h"
|
||||
#include "TLexer.h"
|
||||
#include "TParser.h"
|
||||
|
||||
#include "Strings.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
using namespace antlrcpptest;
|
||||
using namespace org::antlr::v4::runtime;
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
|
||||
ANTLRInputStream input(L"(((x))) * y + z; a + (x * (y ? 0 : 1) + z);");
|
||||
ANTLRInputStream input("🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
|
||||
TLexer lexer(&input);
|
||||
CommonTokenStream tokens(&lexer);
|
||||
|
||||
TParser parser(&tokens);
|
||||
std::shared_ptr<tree::ParseTree> tree = parser.main();
|
||||
|
||||
std::wstring s = tree->toStringTree(&parser) + L"\n";
|
||||
std::wstring s = antlrcpp::s2ws(tree->toStringTree(&parser)) + L"\n";
|
||||
OutputDebugString(s.data());
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -88,13 +88,14 @@
|
|||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;src\atn;src\dfa;src\misc;src\support;src\tree;src\tree\xpath;src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>src/antlrcpp-Prefix.h</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>src/antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -104,13 +105,14 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;src\atn;src\dfa;src\misc;src\support;src\tree;src\tree\xpath;src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>src/antlrcpp-Prefix.h</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>src/antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -121,14 +123,15 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;src\atn;src\dfa;src\misc;src\support;src\tree;src\tree\xpath;src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>src/antlrcpp-Prefix.h</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>src/antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -141,14 +144,15 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;src\atn;src\dfa;src\misc;src\support;src\tree;src\tree\xpath;src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>src/antlrcpp-Prefix.h</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>src/antlrcpp-Prefix.h</ForcedIncludeFiles>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -263,7 +267,7 @@
|
|||
<ClCompile Include="src\support\Arrays.cpp" />
|
||||
<ClCompile Include="src\support\CPPUtils.cpp" />
|
||||
<ClCompile Include="src\support\guid.cpp" />
|
||||
<ClCompile Include="src\support\Strings.cpp" />
|
||||
<ClCompile Include="src\support\StringUtils.cpp" />
|
||||
<ClCompile Include="src\Token.cpp" />
|
||||
<ClCompile Include="src\TokenStream.cpp" />
|
||||
<ClCompile Include="src\TokenStreamRewriter.cpp" />
|
||||
|
@ -282,15 +286,8 @@
|
|||
<ClCompile Include="src\UnbufferedCharStream.cpp" />
|
||||
<ClCompile Include="src\UnbufferedTokenStream.cpp" />
|
||||
<ClCompile Include="src\VocabularyImpl.cpp" />
|
||||
<ClCompile Include="antlrcpp-Prefix.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\antlrcpp-Prefix.h" />
|
||||
<ClInclude Include="src\ANTLRErrorListener.h" />
|
||||
<ClInclude Include="src\ANTLRErrorStrategy.h" />
|
||||
<ClInclude Include="src\ANTLRFileStream.h" />
|
||||
|
@ -407,7 +404,7 @@
|
|||
<ClInclude Include="src\support\CPPUtils.h" />
|
||||
<ClInclude Include="src\support\Declarations.h" />
|
||||
<ClInclude Include="src\support\guid.h" />
|
||||
<ClInclude Include="src\support\Strings.h" />
|
||||
<ClInclude Include="src\support\StringUtils.h" />
|
||||
<ClInclude Include="src\Token.h" />
|
||||
<ClInclude Include="src\TokenFactory.h" />
|
||||
<ClInclude Include="src\TokenSource.h" />
|
||||
|
|
|
@ -357,9 +357,6 @@
|
|||
<ClInclude Include="src\support\guid.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\Strings.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\AbstractParseTreeVisitor.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
|
@ -501,16 +498,17 @@
|
|||
<ClInclude Include="src\misc\Predicate.h">
|
||||
<Filter>Header Files\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\antlrcpp-Prefix.h" />
|
||||
<ClInclude Include="src\RuleContextWithAltNum.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RuntimeMetaData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\StringUtils.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="antlrcpp-Prefix.cpp" />
|
||||
<ClCompile Include="src\ANTLRFileStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -775,9 +773,6 @@
|
|||
<ClCompile Include="src\support\guid.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\support\Strings.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\ErrorNodeImpl.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
|
@ -880,5 +875,8 @@
|
|||
<ClCompile Include="src\RuntimeMetaData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\support\StringUtils.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -169,8 +169,12 @@ namespace antlrcpp {
|
|||
{
|
||||
try
|
||||
{
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023026
|
||||
return nullptr; // No nested exceptions before VS 2015.
|
||||
#else
|
||||
auto nested = dynamic_cast<const std::nested_exception&>(e);
|
||||
return nested.nested_ptr();
|
||||
#endif
|
||||
}
|
||||
catch (const std::bad_cast &)
|
||||
{ return nullptr; }
|
||||
|
@ -217,4 +221,8 @@ namespace antlrcpp {
|
|||
return result;
|
||||
}
|
||||
|
||||
FinalAction finally(std::function<void ()> f) {
|
||||
return FinalAction(f);
|
||||
}
|
||||
|
||||
} // namespace antlrcpp
|
||||
|
|
|
@ -43,19 +43,23 @@ namespace antlrcpp {
|
|||
std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
|
||||
std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
|
||||
|
||||
// Using RAII + a lambda to implement a "finally" relacement.
|
||||
template <typename F>
|
||||
// Using RAII + a lambda to implement a "finally" replacement.
|
||||
struct FinalAction {
|
||||
FinalAction(F f) : _cleanUp { f } {}
|
||||
FinalAction(std::function<void ()> f) : _cleanUp { f } {}
|
||||
FinalAction(FinalAction &&other) {
|
||||
_cleanUp = other._cleanUp;
|
||||
_enabled = other._enabled;
|
||||
other._enabled = false; // Don't trigger the lambda after ownership has moved.
|
||||
}
|
||||
~FinalAction() { if (_enabled) _cleanUp(); }
|
||||
|
||||
void disable() { _enabled = false; };
|
||||
private:
|
||||
F _cleanUp;
|
||||
std::function<void ()> _cleanUp;
|
||||
bool _enabled {true};
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
FinalAction<F> finally(F f) { return FinalAction<F>(f); }
|
||||
ANTLR4CPP_PUBLIC FinalAction finally(std::function<void ()> f);
|
||||
|
||||
// Convenience functions to avoid lengthy dynamic_cast() != nullptr checks in many places.
|
||||
template <typename T1, typename T2>
|
||||
|
|
|
@ -37,4 +37,7 @@ namespace antlrcpp {
|
|||
static std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utfConverter;
|
||||
|
||||
void replaceAll(std::string& str, const std::string& from, const std::string& to);
|
||||
|
||||
ANTLR4CPP_PUBLIC std::string ws2s(const std::wstring &wstr);
|
||||
ANTLR4CPP_PUBLIC std::wstring s2ws(const std::string &str);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef GUID_ANDROID
|
||||
#include <jni.h>
|
||||
|
|
Loading…
Reference in New Issue