Initial commit from sysy-main

This commit is contained in:
Lixuanwang
2025-02-27 23:14:53 +08:00
commit cc523fd30b
1125 changed files with 257793 additions and 0 deletions

View File

@ -0,0 +1,80 @@
# -*- mode:cmake -*-
if(NOT UNIX)
message(WARNING "Unsupported operating system")
endif()
set(antlr4-demo-GENERATED_SRC
${PROJECT_SOURCE_DIR}/demo/generated/TLexer.cpp
${PROJECT_SOURCE_DIR}/demo/generated/TParser.cpp
${PROJECT_SOURCE_DIR}/demo/generated/TParserBaseListener.cpp
${PROJECT_SOURCE_DIR}/demo/generated/TParserBaseVisitor.cpp
${PROJECT_SOURCE_DIR}/demo/generated/TParserListener.cpp
${PROJECT_SOURCE_DIR}/demo/generated/TParserVisitor.cpp
)
foreach(src_file ${antlr4-demo-GENERATED_SRC})
set_source_files_properties(
${src_file}
PROPERTIES
GENERATED TRUE
)
endforeach(src_file ${antlr4-demo-GENERATED_SRC})
add_custom_target(GenerateParser DEPENDS ${antlr4-demo-GENERATED_SRC})
add_custom_command(OUTPUT ${antlr4-demo-GENERATED_SRC}
COMMAND
${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/demo/generated/
COMMAND
"${Java_JAVA_EXECUTABLE}" -jar ${ANTLR_JAR_LOCATION} -Werror -Dlanguage=Cpp -listener -visitor -o ${PROJECT_SOURCE_DIR}/demo/generated/ -package antlrcpptest ${PROJECT_SOURCE_DIR}/demo/TLexer.g4 ${PROJECT_SOURCE_DIR}/demo/TParser.g4
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS ${PROJECT_SOURCE_DIR}/demo/TLexer.g4 ${PROJECT_SOURCE_DIR}/demo/TParser.g4
)
include_directories(
${PROJECT_SOURCE_DIR}/runtime/src
${PROJECT_SOURCE_DIR}/runtime/src/misc
${PROJECT_SOURCE_DIR}/runtime/src/atn
${PROJECT_SOURCE_DIR}/runtime/src/dfa
${PROJECT_SOURCE_DIR}/runtime/src/tree
${PROJECT_SOURCE_DIR}/runtime/src/support
${PROJECT_SOURCE_DIR}/demo/generated
)
#file(GLOB antlr4-demo_SRC "${PROJECT_SOURCE_DIR}/demo/generated/*")
set(antlr4-demo_SRC
${PROJECT_SOURCE_DIR}/demo/Linux/main.cpp
${antlr4-demo-GENERATED_SRC}
)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set (flags_1 "-Wno-overloaded-virtual")
else()
set (flags_1 "-MP /wd4251")
endif()
foreach(src_file ${antlr4-demo_SRC})
set_source_files_properties(
${src_file}
PROPERTIES
COMPILE_FLAGS "${COMPILE_FLAGS} ${flags_1}"
)
endforeach(src_file ${antlr4-demo_SRC})
add_executable(antlr4-demo
${antlr4-demo_SRC}
)
#add_precompiled_header(antlr4-demo ${PROJECT_SOURCE_DIR}/runtime/src/antlrcpp-Prefix.h)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(antlr4-demo PRIVATE "/MT$<$<CONFIG:Debug>:d>")
endif()
add_dependencies(antlr4-demo GenerateParser)
target_link_libraries(antlr4-demo antlr4_static)
install(TARGETS antlr4-demo
DESTINATION "share"
COMPONENT dev
)

View File

@ -0,0 +1,38 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
//
// main.cpp
// antlr4-cpp-demo
//
// Created by Mike Lischke on 13.03.16.
//
#include <iostream>
#include "antlr4-runtime.h"
#include "TLexer.h"
#include "TParser.h"
using namespace antlrcpptest;
using namespace antlr4;
int main(int , const char **) {
ANTLRInputStream input(u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
TLexer lexer(&input);
CommonTokenStream tokens(&lexer);
tokens.fill();
for (auto token : tokens.getTokens()) {
std::cout << token->toString() << std::endl;
}
TParser parser(&tokens);
tree::ParseTree* tree = parser.main();
std::cout << tree->toStringTree(&parser) << std::endl << std::endl;
return 0;
}

View File

@ -0,0 +1,38 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
//
// main.cpp
// antlr4-cpp-demo
//
// Created by Mike Lischke on 13.03.16.
//
#include <iostream>
#include "antlr4-runtime.h"
#include "TLexer.h"
#include "TParser.h"
using namespace antlrcpptest;
using namespace antlr4;
int main(int , const char **) {
ANTLRInputStream input(u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
TLexer lexer(&input);
CommonTokenStream tokens(&lexer);
tokens.fill();
for (auto token : tokens.getTokens()) {
std::cout << token->toString() << std::endl;
}
TParser parser(&tokens);
tree::ParseTree *tree = parser.main();
std::cout << tree->toStringTree(&parser) << std::endl;
return 0;
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -0,0 +1,172 @@
/*
* [The "BSD license"]
* Copyright (c) 2016 Mike Lischke
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <XCTest/XCTest.h>
#include "ANTLRInputStream.h"
#include "Exceptions.h"
#include "Interval.h"
#include "UnbufferedTokenStream.h"
#include "StringUtils.h"
using namespace antlrcpp;
using namespace antlr4;
using namespace antlr4::misc;
@interface InputHandlingTests : XCTestCase
@end
@implementation InputHandlingTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testANTLRInputStreamCreation {
ANTLRInputStream stream1;
XCTAssert(stream1.toString().empty());
XCTAssertEqual(stream1.index(), 0U);
ANTLRInputStream stream2("To be or not to be");
XCTAssert(stream2.toString() == "To be or not to be");
XCTAssertEqual(stream2.index(), 0U);
XCTAssertEqual(stream2.size(), 18U);
char data[] = "Lorem ipsum dolor sit amet";
ANTLRInputStream stream3(data, sizeof(data) / sizeof(data[0]));
XCTAssert(stream3.toString() == std::string("Lorem ipsum dolor sit amet\0", 27));
XCTAssertEqual(stream3.index(), 0U);
XCTAssertEqual(stream3.size(), 27U);
std::stringstream input("Lorem ipsum dolor sit amet");
ANTLRInputStream stream4(input);
std::string content = stream4.toString();
XCTAssertEqual(content, "Lorem ipsum dolor sit amet"); // Now as utf-8 string.
XCTAssertEqual(stream4.index(), 0U);
XCTAssertEqual(stream4.size(), 26U);
std::string longString(33333, 'a');
input.str(longString);
stream4.load(input);
XCTAssertEqual(stream4.index(), 0U);
XCTAssertEqual(stream4.size(), 33333U);
input.clear();
stream4.load(input);
XCTAssertEqual(stream4.size(), 0U);
}
- (void)testANTLRInputStreamUse {
std::string text(u8"🚧Lorem ipsum dolor sit amet🕶");
std::u32string wtext = utf8_to_utf32(text.c_str(), text.c_str() + text.size()); // Convert to UTF-32.
ANTLRInputStream stream(text);
XCTAssertEqual(stream.index(), 0U);
XCTAssertEqual(stream.size(), wtext.size());
for (size_t i = 0; i < stream.size(); ++i) {
stream.consume();
XCTAssertEqual(stream.index(), i + 1);
}
try {
stream.consume();
XCTFail();
} catch (IllegalStateException &e) {
// Expected.
std::string message = e.what();
XCTAssertEqual(message, "cannot consume EOF");
}
XCTAssertEqual(stream.index(), wtext.size());
stream.reset();
XCTAssertEqual(stream.index(), 0U);
XCTAssertEqual(stream.LA(0), 0ULL);
for (size_t i = 1; i < wtext.size(); ++i) {
XCTAssertEqual(stream.LA(static_cast<ssize_t>(i)), wtext[i - 1]); // LA(1) means: current char.
XCTAssertEqual(stream.LT(static_cast<ssize_t>(i)), wtext[i - 1]); // LT is mapped to LA.
XCTAssertEqual(stream.index(), 0U); // No consumption when looking ahead.
}
stream.seek(wtext.size() - 1);
XCTAssertEqual(stream.index(), wtext.size() - 1);
stream.seek(wtext.size() / 2);
XCTAssertEqual(stream.index(), wtext.size() / 2);
stream.seek(wtext.size() - 1);
for (ssize_t i = 1; i < static_cast<ssize_t>(wtext.size()) - 1; ++i) {
XCTAssertEqual(stream.LA(-i), wtext[wtext.size() - i - 1]); // LA(-1) means: previous char.
XCTAssertEqual(stream.LT(-i), wtext[wtext.size() - i - 1]); // LT is mapped to LA.
XCTAssertEqual(stream.index(), wtext.size() - 1); // No consumption when looking ahead.
}
XCTAssertEqual(stream.LA(-10000), IntStream::EOF);
// Mark and release do nothing.
stream.reset();
XCTAssertEqual(stream.index(), 0U);
ssize_t marker = stream.mark();
XCTAssertEqual(marker, -1);
stream.seek(10);
XCTAssertEqual(stream.index(), 10U);
XCTAssertEqual(stream.mark(), -1);
stream.release(marker);
XCTAssertEqual(stream.index(), 10U);
misc::Interval interval1(2, 10UL); // From - to, inclusive.
std::string output = stream.getText(interval1);
std::string sub = utf32_to_utf8(wtext.substr(2, 9));
XCTAssertEqual(output, sub);
misc::Interval interval2(200, 10UL); // Start beyond bounds.
output = stream.getText(interval2);
XCTAssert(output.empty());
misc::Interval interval3(0, 200UL); // End beyond bounds.
output = stream.getText(interval3);
XCTAssertEqual(output, text);
stream.name = "unit tests"; // Quite useless test, as "name" is a public field.
XCTAssertEqual(stream.getSourceName(), "unit tests");
}
- (void)testUnbufferedTokenSteam {
//UnbufferedTokenStream stream;
}
@end

View File

@ -0,0 +1,388 @@
/*
* [The "BSD license"]
* Copyright (c) 2016 Mike Lischke
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <XCTest/XCTest.h>
#include "antlr4-runtime.h"
using namespace antlr4;
using namespace antlr4::misc;
using namespace antlrcpp;
@interface MiscClassTests : XCTestCase
@end
@implementation MiscClassTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testCPPUtils {
class A { public: virtual ~A() {}; };
class B : public A { public: virtual ~B() {}; };
class C : public A { public: virtual ~C() {}; };
class D : public C { public: virtual ~D() {}; };
{
A *a = new A(); B *b = new B(); C *c = new C(); D *d = new D();
XCTAssert(is<A*>(b));
XCTAssertFalse(is<B*>(a));
XCTAssert(is<A*>(c));
XCTAssertFalse(is<B*>(c));
XCTAssert(is<A*>(d));
XCTAssert(is<C*>(d));
XCTAssertFalse(is<B*>(d));
delete a; delete b; delete c; delete d;
}
{
Ref<A> a(new A());
Ref<B> b(new B());
Ref<C> c(new C());
Ref<D> d(new D());
XCTAssert(is<A>(b));
XCTAssertFalse(is<B>(a));
XCTAssert(is<A>(c));
XCTAssertFalse(is<B>(c));
XCTAssert(is<A>(d));
XCTAssert(is<C>(d));
XCTAssertFalse(is<B>(d));
}
}
- (void)testMurmurHash {
XCTAssertEqual(MurmurHash::initialize(), 0U);
XCTAssertEqual(MurmurHash::initialize(31), 31U);
// In absence of real test vectors (64bit) for murmurhash I instead check if I can find duplicate hash values
// in a deterministic and a random sequence of 100K values each.
std::set<size_t> hashs;
for (size_t i = 0; i < 100000; ++i) {
std::vector<size_t> data = { i, static_cast<size_t>(i * M_PI), arc4random() };
size_t hash = 0;
for (auto value : data)
hash = MurmurHash::update(hash, value);
hash = MurmurHash::finish(hash, data.size());
hashs.insert(hash);
}
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
hashs.clear();
for (size_t i = 0; i < 100000; ++i) {
std::vector<size_t> data = { i, static_cast<size_t>(i * M_PI) };
size_t hash = 0;
for (auto value : data)
hash = MurmurHash::update(hash, value);
hash = MurmurHash::finish(hash, data.size());
hashs.insert(hash);
}
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
// Another test with fixed input but varying seeds.
// Note: the higher the seed the less LSDs are in the result (for small input data).
hashs.clear();
std::vector<size_t> data = { L'µ', 'a', '@', '1' };
for (size_t i = 0; i < 100000; ++i) {
size_t hash = i;
for (auto value : data)
hash = MurmurHash::update(hash, value);
hash = MurmurHash::finish(hash, data.size());
hashs.insert(hash);
}
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
}
- (void)testInterval {
// The Interval class contains no error handling (checks for invalid intervals), hence some of the results
// look strange as we test of course such intervals as well.
XCTAssertEqual(Interval().length(), 0UL);
XCTAssertEqual(Interval(0, 0UL).length(), 1UL); // Remember: it's an inclusive interval.
XCTAssertEqual(Interval(100, 100UL).length(), 1UL);
XCTAssertEqual(Interval(-1L, -1).length(), 1UL); // Unwanted behavior: negative ranges.
XCTAssertEqual(Interval(-1L, -2).length(), 0UL);
XCTAssertEqual(Interval(100, 50UL).length(), 0UL);
XCTAssert(Interval() == Interval(-1L, -2));
XCTAssert(Interval(0, 0UL) == Interval(0, 0UL));
XCTAssertFalse(Interval(0, 1UL) == Interval(1, 2UL));
XCTAssertEqual(Interval().hashCode(), 22070U);
XCTAssertEqual(Interval(0, 0UL).hashCode(), 22103U);
XCTAssertEqual(Interval(10, 2000UL).hashCode(), 24413U);
// Results for the interval test functions in this order:
// startsBeforeDisjoint
// startsBeforeNonDisjoint
// startsAfter
// startsAfterDisjoint
// startsAfterNonDisjoint
// disjoint
// adjacent
// properlyContains
typedef std::vector<bool> TestResults;
struct TestEntry { size_t runningNumber; Interval interval1, interval2; TestResults results; };
std::vector<TestEntry> testData = {
// Extreme cases + invalid intervals.
{ 0, Interval(), Interval(10, 20UL), { true, false, false, false, false, true, false, false } },
{ 1, Interval(1, 1UL), Interval(1, 1UL), { false, true, false, false, false, false, false, true } },
{ 2, Interval(10000, 10000UL), Interval(10000, 10000UL), { false, true, false, false, false, false, false, true } },
{ 3, Interval(100, 10UL), Interval(100, 10UL), { false, false, false, true, false, true, false, true } },
{ 4, Interval(100, 10UL), Interval(10, 100UL), { false, false, true, false, true, false, false, false } },
{ 5, Interval(10, 100UL), Interval(100, 10UL), { false, true, false, false, false, false, false, true } },
// First starts before second. End varies.
{ 20, Interval(10, 12UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 21, Interval(10, 12UL), Interval(13, 100UL), { true, false, false, false, false, true, true, false } },
{ 22, Interval(10, 12UL), Interval(14, 100UL), { true, false, false, false, false, true, false, false } },
{ 23, Interval(10, 13UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 24, Interval(10, 14UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 25, Interval(10, 99UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 26, Interval(10, 100UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
{ 27, Interval(10, 101UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
{ 28, Interval(10, 1000UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
// First and second start equal. End varies.
{ 30, Interval(12, 12UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 31, Interval(12, 12UL), Interval(13, 100UL), { true, false, false, false, false, true, true, false } },
{ 32, Interval(12, 12UL), Interval(14, 100UL), { true, false, false, false, false, true, false, false } },
{ 33, Interval(12, 13UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 34, Interval(12, 14UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 35, Interval(12, 99UL), Interval(12, 100UL), { false, true, false, false, false, false, false, false } },
{ 36, Interval(12, 100UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
{ 37, Interval(12, 101UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
{ 38, Interval(12, 1000UL), Interval(12, 100UL), { false, true, false, false, false, false, false, true } },
// First starts after second. End varies.
{ 40, Interval(15, 12UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
{ 41, Interval(15, 12UL), Interval(13, 100UL), { false, false, true, false, true, false, true, false } },
{ 42, Interval(15, 12UL), Interval(14, 100UL), { false, false, true, false, true, false, false, false } },
{ 43, Interval(15, 13UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
{ 44, Interval(15, 14UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
{ 45, Interval(15, 99UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
{ 46, Interval(15, 100UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
{ 47, Interval(15, 101UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
{ 48, Interval(15, 1000UL), Interval(12, 100UL), { false, false, true, false, true, false, false, false } },
// First ends before second. Start varies.
{ 50, Interval(10, 90UL), Interval(20, 100UL), { false, true, false, false, false, false, false, false } },
{ 51, Interval(19, 90UL), Interval(20, 100UL), { false, true, false, false, false, false, false, false } },
{ 52, Interval(20, 90UL), Interval(20, 100UL), { false, true, false, false, false, false, false, false } },
{ 53, Interval(21, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 54, Interval(98, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 55, Interval(99, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 56, Interval(100, 90UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 57, Interval(101, 90UL), Interval(20, 100UL), { false, false, true, true, false, true, true, false } },
{ 58, Interval(1000, 90UL), Interval(20, 100UL), { false, false, true, true, false, true, false, false } },
// First and second end equal. Start varies.
{ 60, Interval(10, 100UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
{ 61, Interval(19, 100UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
{ 62, Interval(20, 100UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
{ 63, Interval(21, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 64, Interval(98, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 65, Interval(99, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 66, Interval(100, 100UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 67, Interval(101, 100UL), Interval(20, 100UL), { false, false, true, true, false, true, true, false } },
{ 68, Interval(1000, 100UL), Interval(20, 100UL), { false, false, true, true, false, true, false, false } },
// First ends after second. Start varies.
{ 70, Interval(10, 1000UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
{ 71, Interval(19, 1000UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
{ 72, Interval(20, 1000UL), Interval(20, 100UL), { false, true, false, false, false, false, false, true } },
{ 73, Interval(21, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 74, Interval(98, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 75, Interval(99, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 76, Interval(100, 1000UL), Interval(20, 100UL), { false, false, true, false, true, false, false, false } },
{ 77, Interval(101, 1000UL), Interval(20, 100UL), { false, false, true, true, false, true, true, false } },
{ 78, Interval(1000, 1000UL), Interval(20, 100UL), { false, false, true, true, false, true, false, false } },
// It's possible to add more tests with borders that touch each other (e.g. first starts before/on/after second
// and first ends directly before/after second. However, such cases are not handled differently in the Interval
// class
// (only adjacent intervals, where first ends directly before second starts and vice versa. So I ommitted them here.
};
for (auto &entry : testData) {
XCTAssert(entry.interval1.startsBeforeDisjoint(entry.interval2) == entry.results[0], @"entry: %zu",
entry.runningNumber);
XCTAssert(entry.interval1.startsBeforeNonDisjoint(entry.interval2) == entry.results[1], @"entry: %zu",
entry.runningNumber);
XCTAssert(entry.interval1.startsAfter(entry.interval2) == entry.results[2], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.startsAfterDisjoint(entry.interval2) == entry.results[3], @"entry: %zu",
entry.runningNumber);
XCTAssert(entry.interval1.startsAfterNonDisjoint(entry.interval2) == entry.results[4], @"entry: %zu",
entry.runningNumber);
XCTAssert(entry.interval1.disjoint(entry.interval2) == entry.results[5], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.adjacent(entry.interval2) == entry.results[6], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.properlyContains(entry.interval2) == entry.results[7], @"entry: %zu",
entry.runningNumber);
}
XCTAssert(Interval().Union(Interval(10, 100UL)) == Interval(-1L, 100));
XCTAssert(Interval(10, 10UL).Union(Interval(10, 100UL)) == Interval(10, 100UL));
XCTAssert(Interval(10, 11UL).Union(Interval(10, 100UL)) == Interval(10, 100UL));
XCTAssert(Interval(10, 1000UL).Union(Interval(10, 100UL)) == Interval(10, 1000UL));
XCTAssert(Interval(1000, 30UL).Union(Interval(10, 100UL)) == Interval(10, 100UL));
XCTAssert(Interval(1000, 2000UL).Union(Interval(10, 100UL)) == Interval(10, 2000UL));
XCTAssert(Interval(500, 2000UL).Union(Interval(10, 1000UL)) == Interval(10, 2000UL));
XCTAssert(Interval().intersection(Interval(10, 100UL)) == Interval(10, -2L));
XCTAssert(Interval(10, 10UL).intersection(Interval(10, 100UL)) == Interval(10, 10UL));
XCTAssert(Interval(10, 11UL).intersection(Interval(10, 100UL)) == Interval(10, 11UL));
XCTAssert(Interval(10, 1000UL).intersection(Interval(10, 100UL)) == Interval(10, 100UL));
XCTAssert(Interval(1000, 30UL).intersection(Interval(10, 100UL)) == Interval(1000, 30UL));
XCTAssert(Interval(1000, 2000UL).intersection(Interval(10, 100UL)) == Interval(1000, 100UL));
XCTAssert(Interval(500, 2000UL).intersection(Interval(10, 1000UL)) == Interval(500, 1000UL));
XCTAssert(Interval().toString() == "-1..-2");
XCTAssert(Interval(10, 10UL).toString() == "10..10");
XCTAssert(Interval(1000, 2000UL).toString() == "1000..2000");
XCTAssert(Interval(500UL, INT_MAX).toString() == "500.." + std::to_string(INT_MAX));
}
- (void)testIntervalSet {
XCTAssertFalse(IntervalSet().isReadOnly());
XCTAssert(IntervalSet().isEmpty());
IntervalSet set1;
set1.setReadOnly(true);
XCTAssert(set1.isReadOnly());
XCTAssert(IntervalSet() == IntervalSet::EMPTY_SET);
std::vector<Interval> intervals = { Interval(), Interval(10, 20UL), Interval(20, 100UL), Interval(1000, 2000UL) };
IntervalSet set2(intervals);
XCTAssertFalse(set2.isEmpty());
XCTAssertFalse(set2.contains(9UL));
XCTAssert(set2.contains(10UL));
XCTAssert(set2.contains(20UL));
XCTAssertTrue(set2.contains(22UL));
XCTAssert(set2.contains(1111UL));
XCTAssertFalse(set2.contains(10000UL));
XCTAssertEqual(set2.getSingleElement(), Token::INVALID_TYPE);
XCTAssertEqual(set2.getMinElement(), -1);
XCTAssertEqual(set2.getMaxElement(), 2000);
IntervalSet set3(set2);
XCTAssertFalse(set3.isEmpty());
XCTAssertFalse(set3.contains(9UL));
XCTAssert(set3.contains(10UL));
XCTAssert(set3.contains(20UL));
XCTAssertTrue(set3.contains(22UL));
XCTAssert(set3.contains(1111UL));
XCTAssertFalse(set3.contains(10000UL));
XCTAssertEqual(set3.getSingleElement(), Token::INVALID_TYPE);
XCTAssertEqual(set3.getMinElement(), 10);
XCTAssertEqual(set3.getMaxElement(), 2000);
set3.add(Interval(100, 1000UL));
XCTAssertEqual(set3.getMinElement(), 10);
set3.add(Interval(9, 1000UL));
XCTAssertEqual(set3.getMinElement(), 9);
set3.add(Interval(1, 1UL));
XCTAssertEqual(set3.getMinElement(), 1);
IntervalSet set4;
set4.add(10);
XCTAssertEqual(set4.getSingleElement(), 10);
XCTAssertEqual(set4.getMinElement(), 10);
XCTAssertEqual(set4.getMaxElement(), 10);
set4.clear();
XCTAssert(set4.isEmpty());
set4.add(Interval(10, 10UL));
XCTAssertEqual(set4.getSingleElement(), 10);
XCTAssertEqual(set4.getMinElement(), 10);
XCTAssertEqual(set4.getMaxElement(), 10);
set4.setReadOnly(true);
try {
set4.clear();
XCTFail(@"Expected exception");
} catch (IllegalStateException &e) {
}
try {
set4.setReadOnly(false);
XCTFail(@"Expected exception");
} catch (IllegalStateException &e) {
}
try {
set4 = IntervalSet::of(12345);
XCTFail(@"Expected exception");
} catch (IllegalStateException &e) {
}
IntervalSet set5 = IntervalSet::of(12345);
XCTAssertEqual(set5.getSingleElement(), 12345);
XCTAssertEqual(set5.getMinElement(), 12345);
XCTAssertEqual(set5.getMaxElement(), 12345);
IntervalSet set6(10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
XCTAssertEqual(set6.getMinElement(), 5);
XCTAssertEqual(set6.getMaxElement(), 50);
XCTAssertEqual(set6.size(), 10U);
set6.add(12, 18);
XCTAssertEqual(set6.size(), 16U); // (15, 15) replaced by (12, 18)
set6.add(9, 33);
XCTAssertEqual(set6.size(), 30U); // (10, 10), (12, 18), (20, 20), (25, 25) and (30, 30) replaced by (9, 33)
XCTAssert(IntervalSet(3, 1, 2, 10).Or(IntervalSet(3, 1, 2, 5)) == IntervalSet(4, 1, 2, 5, 10));
XCTAssert(IntervalSet({ Interval(2, 10UL) }).Or(IntervalSet({ Interval(5, 8UL) })) == IntervalSet({ Interval(2, 10UL) }));
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(7, 55)) == IntervalSet::of(11, 55));
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(20, 55)) == IntervalSet::of(20, 55));
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(5, 6)) == IntervalSet::EMPTY_SET);
XCTAssert(IntervalSet::of(15, 20).complement(IntervalSet::of(7, 55)) ==
IntervalSet({ Interval(7, 14UL), Interval(21, 55UL) }));
XCTAssert(IntervalSet({ Interval(1, 10UL), Interval(30, 35UL) }).complement(IntervalSet::of(7, 55)) ==
IntervalSet({ Interval(11, 29UL), Interval(36, 55UL) }));
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(7, 55)) == IntervalSet::of(7, 10));
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(20, 55)) == IntervalSet::EMPTY_SET);
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(5, 6)) == IntervalSet::of(5, 6));
XCTAssert(IntervalSet::of(15, 20).And(IntervalSet::of(7, 55)) == IntervalSet::of(15, 20));
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(7, 55)) == IntervalSet::of(1, 6));
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(20, 55)) == IntervalSet::of(1, 10));
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(5, 6)) ==
IntervalSet({ Interval(1, 4UL), Interval(7, 10UL) }));
XCTAssert(IntervalSet::of(15, 20).subtract(IntervalSet::of(7, 55)) == IntervalSet::EMPTY_SET);
}
@end

View File

@ -0,0 +1,57 @@
/*
* [The "BSD license"]
* Copyright (c) 2015 Dan McLaughlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
#include "ParserATNSimulator.h"
#include "DFA.h"
#include "ATN.h"
#include <vector>
using namespace antlr4;
@interface antlrcpp_Tests : XCTestCase
@end
@implementation antlrcpp_Tests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
@end

View File

@ -0,0 +1,585 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
2707D9C22764C11300D99A45 /* libantlr4-runtime.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2707D9BC2764C04C00D99A45 /* libantlr4-runtime.dylib */; };
270925B11CDB455B00522D32 /* TLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */; };
2747A7131CA6C46C0030247B /* InputHandlingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2747A7121CA6C46C0030247B /* InputHandlingTests.mm */; };
274FC6D91CA96B6C008D4374 /* MiscClassTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */; };
27C66A6A1C9591280021E494 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C66A691C9591280021E494 /* main.cpp */; };
27C6E1801C972FFC0079AF06 /* TParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1741C972FFC0079AF06 /* TParser.cpp */; };
27C6E1811C972FFC0079AF06 /* TParserBaseListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1771C972FFC0079AF06 /* TParserBaseListener.cpp */; };
27C6E1821C972FFC0079AF06 /* TParserBaseVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */; };
27C6E1831C972FFC0079AF06 /* TParserListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */; };
27C6E1841C972FFC0079AF06 /* TParserVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */; };
37F1356D1B4AC02800E0CACF /* antlrcpp_Tests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
2707D9BB2764C04C00D99A45 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2707D9B52764C04C00D99A45 /* antlrcpp.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 37D727AA1867AF1E007B6D10;
remoteInfo = antlr4;
};
2707D9BD2764C04C00D99A45 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2707D9B52764C04C00D99A45 /* antlrcpp.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 37C147171B4D5A04008EDDDB;
remoteInfo = antlr4_static;
};
2707D9BF2764C04C00D99A45 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2707D9B52764C04C00D99A45 /* antlrcpp.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 270C67F01CDB4F1E00116E17;
remoteInfo = antlr4_ios;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
27C66A651C9591280021E494 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
2707D9B52764C04C00D99A45 /* antlrcpp.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = antlrcpp.xcodeproj; path = ../../runtime/antlrcpp.xcodeproj; sourceTree = "<group>"; };
2747A7121CA6C46C0030247B /* InputHandlingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InputHandlingTests.mm; sourceTree = "<group>"; wrapsLines = 0; };
274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MiscClassTests.mm; sourceTree = "<group>"; wrapsLines = 0; };
27874F1D1CCB7A0700AF1C53 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TLexer.cpp; path = ../generated/TLexer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
27A23EA21CC2A8D60036D8A3 /* TLexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TLexer.h; path = ../generated/TLexer.h; sourceTree = "<group>"; };
27C66A671C9591280021E494 /* antlr4-cpp-demo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "antlr4-cpp-demo"; sourceTree = BUILT_PRODUCTS_DIR; };
27C66A691C9591280021E494 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; wrapsLines = 0; };
27C66A731C9592400021E494 /* TLexer.g4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = TLexer.g4; path = ../../TLexer.g4; sourceTree = "<group>"; };
27C66A741C9592400021E494 /* TParser.g4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = TParser.g4; path = ../../TParser.g4; sourceTree = "<group>"; };
27C6E1741C972FFC0079AF06 /* TParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParser.cpp; path = ../generated/TParser.cpp; sourceTree = "<group>"; wrapsLines = 0; };
27C6E1751C972FFC0079AF06 /* TParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParser.h; path = ../generated/TParser.h; sourceTree = "<group>"; wrapsLines = 0; };
27C6E1771C972FFC0079AF06 /* TParserBaseListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserBaseListener.cpp; path = ../generated/TParserBaseListener.cpp; sourceTree = "<group>"; };
27C6E1781C972FFC0079AF06 /* TParserBaseListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserBaseListener.h; path = ../generated/TParserBaseListener.h; sourceTree = "<group>"; };
27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserBaseVisitor.cpp; path = ../generated/TParserBaseVisitor.cpp; sourceTree = "<group>"; };
27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserListener.cpp; path = ../generated/TParserListener.cpp; sourceTree = "<group>"; };
27C6E17C1C972FFC0079AF06 /* TParserListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserListener.h; path = ../generated/TParserListener.h; sourceTree = "<group>"; };
27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserVisitor.cpp; path = ../generated/TParserVisitor.cpp; sourceTree = "<group>"; };
27C6E1851C97322F0079AF06 /* TParserBaseVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserBaseVisitor.h; path = ../generated/TParserBaseVisitor.h; sourceTree = "<group>"; wrapsLines = 0; };
27C6E1861C97322F0079AF06 /* TParserVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserVisitor.h; path = ../generated/TParserVisitor.h; sourceTree = "<group>"; };
37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "antlrcpp Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
37F1356B1B4AC02800E0CACF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = antlrcpp_Tests.mm; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
27C66A641C9591280021E494 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2707D9C22764C11300D99A45 /* libantlr4-runtime.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
37F135651B4AC02800E0CACF /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
2707D9B62764C04C00D99A45 /* Products */ = {
isa = PBXGroup;
children = (
2707D9BC2764C04C00D99A45 /* libantlr4-runtime.dylib */,
2707D9BE2764C04C00D99A45 /* libantlr4-runtime.a */,
2707D9C02764C04C00D99A45 /* antlr4_ios.framework */,
);
name = Products;
sourceTree = "<group>";
};
2707D9C12764C11300D99A45 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
27874F221CCBB34200AF1C53 /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
27874F1D1CCB7A0700AF1C53 /* CoreFoundation.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
};
27C66A5C1C958EB50021E494 /* generated */ = {
isa = PBXGroup;
children = (
27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */,
27A23EA21CC2A8D60036D8A3 /* TLexer.h */,
27C6E1741C972FFC0079AF06 /* TParser.cpp */,
27C6E1751C972FFC0079AF06 /* TParser.h */,
27C6E1771C972FFC0079AF06 /* TParserBaseListener.cpp */,
27C6E1781C972FFC0079AF06 /* TParserBaseListener.h */,
27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */,
27C6E1851C97322F0079AF06 /* TParserBaseVisitor.h */,
27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */,
27C6E17C1C972FFC0079AF06 /* TParserListener.h */,
27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */,
27C6E1861C97322F0079AF06 /* TParserVisitor.h */,
);
name = generated;
sourceTree = "<group>";
};
27C66A681C9591280021E494 /* antlr4-cpp-demo */ = {
isa = PBXGroup;
children = (
27C66A691C9591280021E494 /* main.cpp */,
27C66A731C9592400021E494 /* TLexer.g4 */,
27C66A741C9592400021E494 /* TParser.g4 */,
);
path = "antlr4-cpp-demo";
sourceTree = "<group>";
};
37D727A11867AF1E007B6D10 = {
isa = PBXGroup;
children = (
2707D9B52764C04C00D99A45 /* antlrcpp.xcodeproj */,
27C66A681C9591280021E494 /* antlr4-cpp-demo */,
37F135691B4AC02800E0CACF /* antlrcpp Tests */,
27C66A5C1C958EB50021E494 /* generated */,
27874F221CCBB34200AF1C53 /* Linked Frameworks */,
37D727AB1867AF1E007B6D10 /* Products */,
2707D9C12764C11300D99A45 /* Frameworks */,
);
sourceTree = "<group>";
};
37D727AB1867AF1E007B6D10 /* Products */ = {
isa = PBXGroup;
children = (
37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */,
27C66A671C9591280021E494 /* antlr4-cpp-demo */,
);
name = Products;
sourceTree = "<group>";
};
37F135691B4AC02800E0CACF /* antlrcpp Tests */ = {
isa = PBXGroup;
children = (
37F1356A1B4AC02800E0CACF /* Supporting Files */,
37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */,
2747A7121CA6C46C0030247B /* InputHandlingTests.mm */,
274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */,
);
path = "antlrcpp Tests";
sourceTree = "<group>";
};
37F1356A1B4AC02800E0CACF /* Supporting Files */ = {
isa = PBXGroup;
children = (
37F1356B1B4AC02800E0CACF /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
27C66A661C9591280021E494 /* antlr4-cpp-demo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 27C66A6B1C9591280021E494 /* Build configuration list for PBXNativeTarget "antlr4-cpp-demo" */;
buildPhases = (
27C66A721C9591EF0021E494 /* Generate Parser */,
27C66A631C9591280021E494 /* Sources */,
27C66A641C9591280021E494 /* Frameworks */,
27C66A651C9591280021E494 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = "antlr4-cpp-demo";
productName = "antlr4-cpp-demo";
productReference = 27C66A671C9591280021E494 /* antlr4-cpp-demo */;
productType = "com.apple.product-type.tool";
};
37F135671B4AC02800E0CACF /* antlrcpp Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 37F135731B4AC02800E0CACF /* Build configuration list for PBXNativeTarget "antlrcpp Tests" */;
buildPhases = (
37F135641B4AC02800E0CACF /* Sources */,
37F135651B4AC02800E0CACF /* Frameworks */,
37F135661B4AC02800E0CACF /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "antlrcpp Tests";
productName = "antlrcpp Tests";
productReference = 37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
37D727A21867AF1E007B6D10 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "ANTLR4 Project";
TargetAttributes = {
27C66A661C9591280021E494 = {
CreatedOnToolsVersion = 7.2.1;
};
37F135671B4AC02800E0CACF = {
CreatedOnToolsVersion = 6.3.2;
};
};
};
buildConfigurationList = 37D727A51867AF1E007B6D10 /* Build configuration list for PBXProject "antlrcpp-demo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 37D727A11867AF1E007B6D10;
productRefGroup = 37D727AB1867AF1E007B6D10 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 2707D9B62764C04C00D99A45 /* Products */;
ProjectRef = 2707D9B52764C04C00D99A45 /* antlrcpp.xcodeproj */;
},
);
projectRoot = "";
targets = (
37F135671B4AC02800E0CACF /* antlrcpp Tests */,
27C66A661C9591280021E494 /* antlr4-cpp-demo */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
2707D9BC2764C04C00D99A45 /* libantlr4-runtime.dylib */ = {
isa = PBXReferenceProxy;
fileType = "compiled.mach-o.dylib";
path = "libantlr4-runtime.dylib";
remoteRef = 2707D9BB2764C04C00D99A45 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
2707D9BE2764C04C00D99A45 /* libantlr4-runtime.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libantlr4-runtime.a";
remoteRef = 2707D9BD2764C04C00D99A45 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
2707D9C02764C04C00D99A45 /* antlr4_ios.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = antlr4_ios.framework;
remoteRef = 2707D9BF2764C04C00D99A45 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
37F135661B4AC02800E0CACF /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
27C66A721C9591EF0021E494 /* Generate Parser */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Generate Parser";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "pushd ..\nif [ TParser.g4 -nt generated/TParser.cpp -o TLexer.g4 -nt generated/TLexer.cpp ]; then\n./generate.sh;\nfi\npopd\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
27C66A631C9591280021E494 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
27C66A6A1C9591280021E494 /* main.cpp in Sources */,
27C6E1821C972FFC0079AF06 /* TParserBaseVisitor.cpp in Sources */,
270925B11CDB455B00522D32 /* TLexer.cpp in Sources */,
27C6E1831C972FFC0079AF06 /* TParserListener.cpp in Sources */,
27C6E1811C972FFC0079AF06 /* TParserBaseListener.cpp in Sources */,
27C6E1841C972FFC0079AF06 /* TParserVisitor.cpp in Sources */,
27C6E1801C972FFC0079AF06 /* TParser.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
37F135641B4AC02800E0CACF /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
37F1356D1B4AC02800E0CACF /* antlrcpp_Tests.mm in Sources */,
2747A7131CA6C46C0030247B /* InputHandlingTests.mm in Sources */,
274FC6D91CA96B6C008D4374 /* MiscClassTests.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
27C66A6C1C9591280021E494 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "-";
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
27C66A6D1C9591280021E494 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
37D727B51867AF1E007B6D10 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../runtime/src/tree/pattern,
../../runtime/src/tree,
../../runtime/src/support,
../../runtime/src/misc,
../../runtime/src/dfa,
../../runtime/src/atn,
../../runtime/src,
);
MACOSX_DEPLOYMENT_TARGET = 11.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
37D727B61867AF1E007B6D10 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../runtime/src/tree/pattern,
../../runtime/src/tree,
../../runtime/src/support,
../../runtime/src/misc,
../../runtime/src/dfa,
../../runtime/src/atn,
../../runtime/src,
);
MACOSX_DEPLOYMENT_TARGET = 11.1;
SDKROOT = macosx;
};
name = Release;
};
37F135711B4AC02800E0CACF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "antlrcpp Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.antlr.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
37F135721B4AC02800E0CACF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "antlrcpp Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.antlr.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
27C66A6B1C9591280021E494 /* Build configuration list for PBXNativeTarget "antlr4-cpp-demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
27C66A6C1C9591280021E494 /* Debug */,
27C66A6D1C9591280021E494 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
37D727A51867AF1E007B6D10 /* Build configuration list for PBXProject "antlrcpp-demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
37D727B51867AF1E007B6D10 /* Debug */,
37D727B61867AF1E007B6D10 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
37F135731B4AC02800E0CACF /* Build configuration list for PBXNativeTarget "antlrcpp Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
37F135711B4AC02800E0CACF /* Debug */,
37F135721B4AC02800E0CACF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 37D727A21867AF1E007B6D10 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37F135671B4AC02800E0CACF"
BuildableName = "antlrcpp Tests.xctest"
BlueprintName = "antlrcpp Tests"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37F135671B4AC02800E0CACF"
BuildableName = "antlrcpp Tests.xctest"
BlueprintName = "antlrcpp Tests"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,43 @@
#!/bin/sh
# [The "BSD license"]
# Copyright (c) 2013 Terence Parr
# Copyright (c) 2013 Dan McLaughlin
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ANTLRCPP_XCODEPROJ="${CURRENT_DIR}/antlrcpp.xcodeproj"
# OS X
xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp -configuration Release $@
xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp -configuration Debug $@
# iOS
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone -configuration Release -sdk iphoneos $@
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone -configuration Debug -sdk iphoneos $@
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone_sim -configuration Release -sdk iphonesimulator $@
#xcrun xcodebuild -project ${ANTLRCPP_XCODEPROJ} -target antlrcpp_iphone_sim -configuration Debug -sdk iphonesimulator $@

View File

@ -0,0 +1,13 @@
## Demo application for the ANTLR 4 C++ target
This demo app shows how to build the ANTLR runtime both as dynamic and static library and how to use a parser generated from a simple demo grammar.
A few steps are necessary to get this to work:
- Download the current ANTLR jar and place it in this folder.
- Open the generation script for your platform (generate.cmd for Windows, generate.sh for *nix/OSX) and update the LOCATION var to the actual name of the jar you downloaded.
- Run the generation script. This will generate a test parser + lexer, along with listener + visitor classes in a subfolder named "generated". This is where the demo application looks for these files.
- Open the project in the folder that matches your system.
- Compile and run.
Compilation is done as described in the [runtime/cpp/readme.md](../README.md) file.

View File

@ -0,0 +1,86 @@
lexer grammar TLexer;
// These are all supported lexer sections:
// Lexer file header. Appears at the top of h + cpp files. Use e.g. for copyrights.
@lexer::header {/* lexer header section */}
// Appears before any #include in h + cpp files.
@lexer::preinclude {/* lexer precinclude section */}
// Follows directly after the standard #includes in h + cpp files.
@lexer::postinclude {
/* lexer postinclude section */
#ifndef _WIN32
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
}
// Directly preceds the lexer class declaration in the h file (e.g. for additional types etc.).
@lexer::context {/* lexer context section */}
// Appears in the public part of the lexer in the h file.
@lexer::members {/* public lexer declarations section */
bool canTestFoo() { return true; }
bool isItFoo() { return true; }
bool isItBar() { return true; }
void myFooLexerAction() { /* do something*/ };
void myBarLexerAction() { /* do something*/ };
}
// Appears in the private part of the lexer in the h file.
@lexer::declarations {/* private lexer declarations/members section */}
// Appears in line with the other class member definitions in the cpp file.
@lexer::definitions {/* lexer definitions section */}
channels { CommentsChannel, DirectiveChannel }
tokens {
DUMMY
}
Return: 'return';
Continue: 'continue';
INT: Digit+;
Digit: [0-9];
ID: LETTER (LETTER | '0'..'9')*;
fragment LETTER : [a-zA-Z\u0080-\u{10FFFF}];
LessThan: '<';
GreaterThan: '>';
Equal: '=';
And: 'and';
Colon: ':';
Semicolon: ';';
Plus: '+';
Minus: '-';
Star: '*';
OpenPar: '(';
ClosePar: ')';
OpenCurly: '{' -> pushMode(Mode1);
CloseCurly: '}' -> popMode;
QuestionMark: '?';
Comma: ',' -> skip;
Dollar: '$' -> more, mode(Mode1);
Ampersand: '&' -> type(DUMMY);
String: '"' .*? '"';
Foo: {canTestFoo()}? 'foo' {isItFoo()}? { myFooLexerAction(); };
Bar: 'bar' {isItBar()}? { myBarLexerAction(); };
Any: Foo Dot Bar? DotDot Baz;
Comment : '#' ~[\r\n]* '\r'? '\n' -> channel(CommentsChannel);
WS: [ \t\r\n]+ -> channel(99);
fragment Baz: 'Baz';
mode Mode1;
Dot: '.';
mode Mode2;
DotDot: '..';

View File

@ -0,0 +1,119 @@
parser grammar TParser;
options {
tokenVocab = TLexer;
}
// These are all supported parser sections:
// Parser file header. Appears at the top in all parser related files. Use e.g. for copyrights.
@parser::header {/* parser/listener/visitor header section */}
// Appears before any #include in h + cpp files.
@parser::preinclude {/* parser precinclude section */}
// Follows directly after the standard #includes in h + cpp files.
@parser::postinclude {
/* parser postinclude section */
#ifndef _WIN32
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
}
// Directly preceeds the parser class declaration in the h file (e.g. for additional types etc.).
@parser::context {/* parser context section */}
// Appears in the private part of the parser in the h file.
// The function bodies could also appear in the definitions section, but I want to maximize
// Java compatibility, so we can also create a Java parser from this grammar.
// Still, some tweaking is necessary after the Java file generation (e.g. bool -> boolean).
@parser::members {
/* public parser declarations/members section */
bool myAction() { return true; }
bool doesItBlend() { return true; }
void cleanUp() {}
void doInit() {}
void doAfter() {}
}
// Appears in the public part of the parser in the h file.
@parser::declarations {/* private parser declarations section */}
// Appears in line with the other class member definitions in the cpp file.
@parser::definitions {/* parser definitions section */}
// Additionally there are similar sections for (base)listener and (base)visitor files.
@parser::listenerpreinclude {/* listener preinclude section */}
@parser::listenerpostinclude {/* listener postinclude section */}
@parser::listenerdeclarations {/* listener public declarations/members section */}
@parser::listenermembers {/* listener private declarations/members section */}
@parser::listenerdefinitions {/* listener definitions section */}
@parser::baselistenerpreinclude {/* base listener preinclude section */}
@parser::baselistenerpostinclude {/* base listener postinclude section */}
@parser::baselistenerdeclarations {/* base listener public declarations/members section */}
@parser::baselistenermembers {/* base listener private declarations/members section */}
@parser::baselistenerdefinitions {/* base listener definitions section */}
@parser::visitorpreinclude {/* visitor preinclude section */}
@parser::visitorpostinclude {/* visitor postinclude section */}
@parser::visitordeclarations {/* visitor public declarations/members section */}
@parser::visitormembers {/* visitor private declarations/members section */}
@parser::visitordefinitions {/* visitor definitions section */}
@parser::basevisitorpreinclude {/* base visitor preinclude section */}
@parser::basevisitorpostinclude {/* base visitor postinclude section */}
@parser::basevisitordeclarations {/* base visitor public declarations/members section */}
@parser::basevisitormembers {/* base visitor private declarations/members section */}
@parser::basevisitordefinitions {/* base visitor definitions section */}
// Actual grammar start.
main: stat+ EOF;
divide : ID (and_ GreaterThan)? {doesItBlend()}?;
and_ @init{ doInit(); } @after { doAfter(); } : And ;
conquer:
divide+
| {doesItBlend()}? and_ { myAction(); }
| ID (LessThan* divide)?? { $ID.text; }
;
// Unused rule to demonstrate some of the special features.
unused[double input = 111] returns [double calculated] locals [int _a, double _b, int _c] @init{ doInit(); } @after { doAfter(); } :
stat
;
catch [...] {
// Replaces the standard exception handling.
}
finally {
cleanUp();
}
unused2:
(unused[1] .)+ (Colon | Semicolon | Plus)? ~Semicolon
;
stat: expr Equal expr Semicolon
| expr Semicolon
;
expr: expr Star expr
| expr Plus expr
| OpenPar expr ClosePar
| <assoc = right> expr QuestionMark expr Colon expr
| <assoc = right> expr Equal expr
| identifier = id
| flowControl
| INT
| String
;
flowControl:
Return expr # Return
| Continue # Continue
;
id: ID;
array : OpenCurly el += INT (Comma el += INT)* CloseCurly;
idarray : OpenCurly element += id (Comma element += id)* CloseCurly;
any: t = .;

View File

@ -0,0 +1,365 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug DLL|Win32">
<Configuration>Debug DLL</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug DLL|x64">
<Configuration>Debug DLL</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug Static|Win32">
<Configuration>Debug Static</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug Static|x64">
<Configuration>Debug Static</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release DLL|Win32">
<Configuration>Release DLL</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release DLL|x64">
<Configuration>Release DLL</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release Static|Win32">
<Configuration>Release Static</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release Static|x64">
<Configuration>Release Static</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{24EC5104-7402-4C76-B66B-27ADBE062D68}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>antlr4cppdemo</RootNamespace>
<ProjectName>antlr4cpp-demo</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\vs-2022\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ANTLR4CPP_STATIC;%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ANTLR4CPP_STATIC;%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ANTLR4CPP_STATIC;%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ANTLR4CPP_STATIC;%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>%(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>
</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\generated\TLexer.cpp" />
<ClCompile Include="..\..\generated\TParser.cpp" />
<ClCompile Include="..\..\generated\TParserBaseListener.cpp" />
<ClCompile Include="..\..\generated\TParserBaseVisitor.cpp" />
<ClCompile Include="..\..\generated\TParserListener.cpp" />
<ClCompile Include="..\..\generated\TParserVisitor.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\generated\TLexer.h" />
<ClInclude Include="..\..\generated\TParser.h" />
<ClInclude Include="..\..\generated\TParserBaseListener.h" />
<ClInclude Include="..\..\generated\TParserBaseVisitor.h" />
<ClInclude Include="..\..\generated\TParserListener.h" />
<ClInclude Include="..\..\generated\TParserVisitor.h" />
<ClInclude Include="main.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\runtime\antlr4cpp-vs2022.vcxproj">
<Project>{a9762991-1b57-4dce-90c0-ee42b96947be}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="generated">
<UniqueIdentifier>{ef397b7b-1192-4d44-93ed-fadaec7622e8}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParser.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserBaseListener.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserBaseVisitor.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserListener.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserVisitor.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TLexer.cpp">
<Filter>generated</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\generated\TLexer.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParser.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserBaseListener.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserBaseVisitor.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserListener.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserVisitor.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,39 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
//
// main.cpp
// antlr4-cpp-demo
//
// Created by Mike Lischke on 13.03.16.
//
#include <iostream>
#include "antlr4-runtime.h"
#include "TLexer.h"
#include "TParser.h"
#include <Windows.h>
#pragma execution_character_set("utf-8")
using namespace antlrcpptest;
using namespace antlr4;
int main(int argc, const char * argv[]) {
ANTLRInputStream input("a = b + \"c\";(((x * d))) * e + f; a + (x * (y ? 0 : 1) + z);");
TLexer lexer(&input);
CommonTokenStream tokens(&lexer);
TParser parser(&tokens);
tree::ParseTree *tree = parser.main();
auto s = tree->toStringTree(&parser);
std::cout << "Parse Tree: " << s << std::endl;
return 0;
}

View File

@ -0,0 +1,61 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "antlr4cpp-vs2022", "..\..\runtime\antlr4cpp-vs2022.vcxproj", "{52618D4B-6EC4-49AD-8B83-52686244E8F3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "antlr4cpp-demo", "antlr4-cpp-demo\antlr4-cpp-demo-vs2022.vcxproj", "{24EC5104-7402-4C76-B66B-27ADBE062D68}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug DLL|x64 = Debug DLL|x64
Debug DLL|x86 = Debug DLL|x86
Debug Static|x64 = Debug Static|x64
Debug Static|x86 = Debug Static|x86
Release DLL|x64 = Release DLL|x64
Release DLL|x86 = Release DLL|x86
Release Static|x64 = Release Static|x64
Release Static|x86 = Release Static|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug DLL|x64.ActiveCfg = Debug DLL|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug DLL|x64.Build.0 = Debug DLL|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug DLL|x86.ActiveCfg = Debug DLL|Win32
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug DLL|x86.Build.0 = Debug DLL|Win32
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug Static|x64.ActiveCfg = Debug Static|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug Static|x64.Build.0 = Debug Static|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug Static|x86.ActiveCfg = Debug Static|Win32
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Debug Static|x86.Build.0 = Debug Static|Win32
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release DLL|x64.ActiveCfg = Release DLL|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release DLL|x64.Build.0 = Release DLL|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release DLL|x86.ActiveCfg = Release DLL|Win32
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release DLL|x86.Build.0 = Release DLL|Win32
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release Static|x64.ActiveCfg = Release Static|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release Static|x64.Build.0 = Release Static|x64
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release Static|x86.ActiveCfg = Release Static|Win32
{52618D4B-6EC4-49AD-8B83-52686244E8F3}.Release Static|x86.Build.0 = Release Static|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug DLL|x64.ActiveCfg = Debug DLL|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug DLL|x64.Build.0 = Debug DLL|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug DLL|x86.ActiveCfg = Debug DLL|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug DLL|x86.Build.0 = Debug DLL|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug Static|x64.ActiveCfg = Debug Static|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug Static|x64.Build.0 = Debug Static|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug Static|x86.ActiveCfg = Debug Static|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug Static|x86.Build.0 = Debug Static|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release DLL|x64.ActiveCfg = Release DLL|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release DLL|x64.Build.0 = Release DLL|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release DLL|x86.ActiveCfg = Release DLL|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release DLL|x86.Build.0 = Release DLL|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release Static|x64.ActiveCfg = Release Static|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release Static|x64.Build.0 = Release Static|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release Static|x86.ActiveCfg = Release Static|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release Static|x86.Build.0 = Release Static|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {93CE9298-807C-4EAD-B1E6-7109DD1A78FA}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,13 @@
@echo off
:: Created 2016, Mike Lischke (public domain)
:: This script is used to generate source files from the test grammars in the same folder. The generated files are placed
:: into a subfolder "generated" which the demo project uses to compile a demo binary.
:: Download the ANLTR jar and place it in the same folder as this script (or adjust the LOCATION var accordingly).
set LOCATION=antlr-4.13.2-complete.jar
java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4

View File

@ -0,0 +1,28 @@
#!/bin/bash
set -o errexit
# Created 2016, Mike Lischke (public domain)
# This script is used to generate source files from the test grammars in the same folder. The generated files are placed
# into a subfolder "generated" which the demo project uses to compile a demo binary.
# There are 2 ways of running the ANTLR generator here.
# 1) Running from jar. Use the given jar (or replace it by another one you built or downloaded) for generation.
#LOCATION=antlr4-4.5.4-SNAPSHOT.jar
#java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
#java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
#java -jar $LOCATION -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
# 2) Running from class path. This requires that you have both antlr3 and antlr4 compiled. In this scenario no installation
# is needed. You just compile the java class files (using "mvn compile" in both the antlr4 and the antlr3 root folders).
# The script then runs the generation using these class files, by specifying them on the classpath.
# Also the string template jar is needed. Adjust CLASSPATH if you have stored the jar in a different folder as this script assumes.
# Furthermore is assumed that the antlr3 folder is located side-by-side with the antlr4 folder. Adjust CLASSPATH if not.
# This approach is especially useful if you are working on a target stg file, as it doesn't require to regenerate the
# antlr jar over and over again.
CLASSPATH=../../../tool/resources/:ST-4.0.8.jar:../../../tool/target/classes:../../../runtime/Java/target/classes:../../../../antlr3/runtime/Java/target/classes
java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
#java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
#java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Java -listener -visitor -o generated/ TLexer.g4 TParser.g4