Skip to content

Commit

Permalink
Merge pull request #1935 from mike-lischke/master
Browse files Browse the repository at this point in the history
Build fixes after previous C++ patch
  • Loading branch information
parrt authored Jul 21, 2017
2 parents c41426c + 8149ff7 commit 2d6a494
Show file tree
Hide file tree
Showing 46 changed files with 526 additions and 272 deletions.
10 changes: 5 additions & 5 deletions runtime/Cpp/demo/Mac/antlrcpp Tests/InputHandlingTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ - (void)testANTLRInputStreamCreation {

- (void)testANTLRInputStreamUse {
std::string text(u8"🚧Lorem ipsum dolor sit amet🕶");
std::u32string wtext = utfConverter.from_bytes(text); // Convert to UTF-32.
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());
Expand All @@ -116,8 +116,8 @@ - (void)testANTLRInputStreamUse {

XCTAssertEqual(stream.LA(0), 0ULL);
for (size_t i = 1; i < wtext.size(); ++i) {
XCTAssertEqual(stream.LA((ssize_t)i), wtext[i - 1]); // LA(1) means: current char.
XCTAssertEqual(stream.LT((ssize_t)i), wtext[i - 1]); // LT is mapped to LA.
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.
}

Expand All @@ -128,7 +128,7 @@ - (void)testANTLRInputStreamUse {
XCTAssertEqual(stream.index(), wtext.size() / 2);

stream.seek(wtext.size() - 1);
for (ssize_t i = 1; i < (ssize_t)wtext.size() - 1; ++i) {
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.
Expand All @@ -150,7 +150,7 @@ - (void)testANTLRInputStreamUse {

misc::Interval interval1(2, 10UL); // From - to, inclusive.
std::string output = stream.getText(interval1);
std::string sub = utfConverter.to_bytes(wtext.substr(2, 9));
std::string sub = utf32_to_utf8(wtext.substr(2, 9));
XCTAssertEqual(output, sub);

misc::Interval interval2(200, 10UL); // Start beyond bounds.
Expand Down
69 changes: 41 additions & 28 deletions runtime/Cpp/demo/Mac/antlrcpp Tests/MiscClassTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ - (void)testMurmurHash {
// 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, (size_t)(i * M_PI), arc4random()};
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);
Expand All @@ -103,7 +103,7 @@ - (void)testMurmurHash {

hashs.clear();
for (size_t i = 0; i < 100000; ++i) {
std::vector<size_t> data = { i, (size_t)(i * M_PI)};
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);
Expand Down Expand Up @@ -232,19 +232,25 @@ - (void)testInterval {
{ 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
// 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.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.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(entry.interval1.properlyContains(entry.interval2) == entry.results[7], @"entry: %zu",
entry.runningNumber);
}

XCTAssert(Interval().Union(Interval(10, 100UL)) == Interval(-1L, 100));
Expand Down Expand Up @@ -327,39 +333,45 @@ - (void)testIntervalSet {
try {
set4.clear();
XCTFail(@"Expected exception");
}
catch (IllegalStateException &e) {
} catch (IllegalStateException &e) {
}

try {
set4.setReadOnly(false);
XCTFail(@"Expected exception");
} catch (IllegalStateException &e) {
}
catch (IllegalStateException &e) {

try {
set4 = IntervalSet::of(12345);
XCTFail(@"Expected exception");
} catch (IllegalStateException &e) {
}
set4 = IntervalSet::of(12345);
XCTAssertEqual(set4.getSingleElement(), 12345);
XCTAssertEqual(set4.getMinElement(), 12345);
XCTAssertEqual(set4.getMaxElement(), 12345);

IntervalSet set5(10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
XCTAssertEqual(set5.getMinElement(), 5);
XCTAssertEqual(set5.getMaxElement(), 50);
XCTAssertEqual(set5.size(), 10U);
set5.add(12, 18);
XCTAssertEqual(set5.size(), 16U); // (15, 15) replaced by (12, 18)
set5.add(9, 33);
XCTAssertEqual(set5.size(), 30U); // (10, 10), (12, 18), (20, 20), (25, 25) and (30, 30) replaced by (9, 33)

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(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);
Expand All @@ -368,7 +380,8 @@ - (void)testIntervalSet {

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(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);
}

Expand Down
3 changes: 2 additions & 1 deletion runtime/Cpp/deploy-windows.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ rem Headers
xcopy runtime\src\*.h antlr4-runtime\ /s

rem Binaries
if exist "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" (
rem VS 2013 disabled by default. Change the X to a C to enable it.
if exist "X:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"

pushd runtime
Expand Down
16 changes: 15 additions & 1 deletion runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\ANTLRErrorListener.cpp" />
<ClCompile Include="src\ANTLRErrorStrategy.cpp" />
<ClCompile Include="src\ANTLRFileStream.cpp" />
<ClCompile Include="src\ANTLRInputStream.cpp" />
<ClCompile Include="src\atn\AbstractPredicateTransition.cpp" />
Expand All @@ -339,13 +341,15 @@
<ClCompile Include="src\atn\BasicBlockStartState.cpp" />
<ClCompile Include="src\atn\BasicState.cpp" />
<ClCompile Include="src\atn\BlockEndState.cpp" />
<ClCompile Include="src\atn\BlockStartState.cpp" />
<ClCompile Include="src\atn\ContextSensitivityInfo.cpp" />
<ClCompile Include="src\atn\DecisionEventInfo.cpp" />
<ClCompile Include="src\atn\DecisionInfo.cpp" />
<ClCompile Include="src\atn\DecisionState.cpp" />
<ClCompile Include="src\atn\EmptyPredictionContext.cpp" />
<ClCompile Include="src\atn\EpsilonTransition.cpp" />
<ClCompile Include="src\atn\ErrorInfo.cpp" />
<ClCompile Include="src\atn\LexerAction.cpp" />
<ClCompile Include="src\atn\LexerActionExecutor.cpp" />
<ClCompile Include="src\atn\LexerATNConfig.cpp" />
<ClCompile Include="src\atn\LexerATNSimulator.cpp" />
Expand Down Expand Up @@ -412,6 +416,7 @@
<ClCompile Include="src\misc\Interval.cpp" />
<ClCompile Include="src\misc\IntervalSet.cpp" />
<ClCompile Include="src\misc\MurmurHash.cpp" />
<ClCompile Include="src\misc\Predicate.cpp" />
<ClCompile Include="src\NoViableAltException.cpp" />
<ClCompile Include="src\Parser.cpp" />
<ClCompile Include="src\ParserInterpreter.cpp" />
Expand All @@ -422,23 +427,31 @@
<ClCompile Include="src\RuleContext.cpp" />
<ClCompile Include="src\RuleContextWithAltNum.cpp" />
<ClCompile Include="src\RuntimeMetaData.cpp" />
<ClCompile Include="src\support\Any.cpp" />
<ClCompile Include="src\support\Arrays.cpp" />
<ClCompile Include="src\support\CPPUtils.cpp" />
<ClCompile Include="src\support\guid.cpp" />
<ClCompile Include="src\support\StringUtils.cpp" />
<ClCompile Include="src\Token.cpp" />
<ClCompile Include="src\TokenSource.cpp" />
<ClCompile Include="src\TokenStream.cpp" />
<ClCompile Include="src\TokenStreamRewriter.cpp" />
<ClCompile Include="src\tree\ErrorNode.cpp" />
<ClCompile Include="src\tree\ErrorNodeImpl.cpp" />
<ClCompile Include="src\tree\IterativeParseTreeWalker.cpp" />
<ClCompile Include="src\tree\ParseTree.cpp" />
<ClCompile Include="src\tree\ParseTreeListener.cpp" />
<ClCompile Include="src\tree\ParseTreeVisitor.cpp" />
<ClCompile Include="src\tree\ParseTreeWalker.cpp" />
<ClCompile Include="src\tree\pattern\Chunk.cpp" />
<ClCompile Include="src\tree\pattern\ParseTreeMatch.cpp" />
<ClCompile Include="src\tree\pattern\ParseTreePattern.cpp" />
<ClCompile Include="src\tree\pattern\ParseTreePatternMatcher.cpp" />
<ClCompile Include="src\tree\pattern\RuleTagToken.cpp" />
<ClCompile Include="src\tree\pattern\TagChunk.cpp" />
<ClCompile Include="src\tree\pattern\TextChunk.cpp" />
<ClCompile Include="src\tree\pattern\TokenTagToken.cpp" />
<ClCompile Include="src\tree\TerminalNode.cpp" />
<ClCompile Include="src\tree\TerminalNodeImpl.cpp" />
<ClCompile Include="src\tree\Trees.cpp" />
<ClCompile Include="src\tree\xpath\XPath.cpp" />
Expand All @@ -454,6 +467,7 @@
<ClCompile Include="src\UnbufferedCharStream.cpp" />
<ClCompile Include="src\UnbufferedTokenStream.cpp" />
<ClCompile Include="src\Vocabulary.cpp" />
<ClCompile Include="src\WritableToken.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\antlr4-common.h" />
Expand Down Expand Up @@ -620,4 +634,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
44 changes: 43 additions & 1 deletion runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -938,5 +938,47 @@
<ClCompile Include="src\tree\IterativeParseTreeWalker.cpp">
<Filter>Source Files\tree</Filter>
</ClCompile>
<ClCompile Include="src\ANTLRErrorListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ANTLRErrorStrategy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Token.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\TokenSource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\WritableToken.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\tree\ErrorNode.cpp">
<Filter>Source Files\tree</Filter>
</ClCompile>
<ClCompile Include="src\tree\ParseTreeListener.cpp">
<Filter>Source Files\tree</Filter>
</ClCompile>
<ClCompile Include="src\tree\ParseTreeVisitor.cpp">
<Filter>Source Files\tree</Filter>
</ClCompile>
<ClCompile Include="src\tree\TerminalNode.cpp">
<Filter>Source Files\tree</Filter>
</ClCompile>
<ClCompile Include="src\support\Any.cpp">
<Filter>Source Files\support</Filter>
</ClCompile>
<ClCompile Include="src\atn\BlockStartState.cpp">
<Filter>Source Files\atn</Filter>
</ClCompile>
<ClCompile Include="src\atn\LexerAction.cpp">
<Filter>Source Files\atn</Filter>
</ClCompile>
<ClCompile Include="src\tree\pattern\Chunk.cpp">
<Filter>Source Files\tree\pattern</Filter>
</ClCompile>
<ClCompile Include="src\misc\Predicate.cpp">
<Filter>Source Files\misc</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>
16 changes: 15 additions & 1 deletion runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\ANTLRErrorListener.cpp" />
<ClCompile Include="src\ANTLRErrorStrategy.cpp" />
<ClCompile Include="src\ANTLRFileStream.cpp" />
<ClCompile Include="src\ANTLRInputStream.cpp" />
<ClCompile Include="src\atn\AbstractPredicateTransition.cpp" />
Expand All @@ -352,13 +354,15 @@
<ClCompile Include="src\atn\BasicBlockStartState.cpp" />
<ClCompile Include="src\atn\BasicState.cpp" />
<ClCompile Include="src\atn\BlockEndState.cpp" />
<ClCompile Include="src\atn\BlockStartState.cpp" />
<ClCompile Include="src\atn\ContextSensitivityInfo.cpp" />
<ClCompile Include="src\atn\DecisionEventInfo.cpp" />
<ClCompile Include="src\atn\DecisionInfo.cpp" />
<ClCompile Include="src\atn\DecisionState.cpp" />
<ClCompile Include="src\atn\EmptyPredictionContext.cpp" />
<ClCompile Include="src\atn\EpsilonTransition.cpp" />
<ClCompile Include="src\atn\ErrorInfo.cpp" />
<ClCompile Include="src\atn\LexerAction.cpp" />
<ClCompile Include="src\atn\LexerActionExecutor.cpp" />
<ClCompile Include="src\atn\LexerATNConfig.cpp" />
<ClCompile Include="src\atn\LexerATNSimulator.cpp" />
Expand Down Expand Up @@ -425,6 +429,7 @@
<ClCompile Include="src\misc\Interval.cpp" />
<ClCompile Include="src\misc\IntervalSet.cpp" />
<ClCompile Include="src\misc\MurmurHash.cpp" />
<ClCompile Include="src\misc\Predicate.cpp" />
<ClCompile Include="src\NoViableAltException.cpp" />
<ClCompile Include="src\Parser.cpp" />
<ClCompile Include="src\ParserInterpreter.cpp" />
Expand All @@ -435,23 +440,31 @@
<ClCompile Include="src\RuleContext.cpp" />
<ClCompile Include="src\RuleContextWithAltNum.cpp" />
<ClCompile Include="src\RuntimeMetaData.cpp" />
<ClCompile Include="src\support\Any.cpp" />
<ClCompile Include="src\support\Arrays.cpp" />
<ClCompile Include="src\support\CPPUtils.cpp" />
<ClCompile Include="src\support\guid.cpp" />
<ClCompile Include="src\support\StringUtils.cpp" />
<ClCompile Include="src\Token.cpp" />
<ClCompile Include="src\TokenSource.cpp" />
<ClCompile Include="src\TokenStream.cpp" />
<ClCompile Include="src\TokenStreamRewriter.cpp" />
<ClCompile Include="src\tree\ErrorNode.cpp" />
<ClCompile Include="src\tree\ErrorNodeImpl.cpp" />
<ClCompile Include="src\tree\IterativeParseTreeWalker.cpp" />
<ClCompile Include="src\tree\ParseTree.cpp" />
<ClCompile Include="src\tree\ParseTreeListener.cpp" />
<ClCompile Include="src\tree\ParseTreeVisitor.cpp" />
<ClCompile Include="src\tree\ParseTreeWalker.cpp" />
<ClCompile Include="src\tree\pattern\Chunk.cpp" />
<ClCompile Include="src\tree\pattern\ParseTreeMatch.cpp" />
<ClCompile Include="src\tree\pattern\ParseTreePattern.cpp" />
<ClCompile Include="src\tree\pattern\ParseTreePatternMatcher.cpp" />
<ClCompile Include="src\tree\pattern\RuleTagToken.cpp" />
<ClCompile Include="src\tree\pattern\TagChunk.cpp" />
<ClCompile Include="src\tree\pattern\TextChunk.cpp" />
<ClCompile Include="src\tree\pattern\TokenTagToken.cpp" />
<ClCompile Include="src\tree\TerminalNode.cpp" />
<ClCompile Include="src\tree\TerminalNodeImpl.cpp" />
<ClCompile Include="src\tree\Trees.cpp" />
<ClCompile Include="src\tree\xpath\XPath.cpp" />
Expand All @@ -467,6 +480,7 @@
<ClCompile Include="src\UnbufferedCharStream.cpp" />
<ClCompile Include="src\UnbufferedTokenStream.cpp" />
<ClCompile Include="src\Vocabulary.cpp" />
<ClCompile Include="src\WritableToken.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\antlr4-common.h" />
Expand Down Expand Up @@ -633,4 +647,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
Loading

0 comments on commit 2d6a494

Please sign in to comment.