forked from jasder/antlr
Switching to current ANTLR revision, part 2.
- Finished adding all new ATN related classes (e.g. profiling infos, lexer actions). - Introduced a global Ref<X> alias for std::shared_ptr<X>. The previous approach (defining a type individually for each class led to cyclic #includes). - Converted all ::Ref typedefs and uses to the new Ref template (+ a number of std::shared_ptr<> occurances). Work in progress still, all those occurences will be converted for 100% consistency.
This commit is contained in:
parent
f8341c7820
commit
8cd043a6de
|
@ -23,7 +23,7 @@ int main(int argc, const char * argv[]) {
|
||||||
CommonTokenStream tokens(&lexer);
|
CommonTokenStream tokens(&lexer);
|
||||||
|
|
||||||
TParser parser(&tokens);
|
TParser parser(&tokens);
|
||||||
std::shared_ptr<tree::ParseTree> tree = parser.main();
|
Ref<tree::ParseTree> tree = parser.main();
|
||||||
|
|
||||||
std::cout << antlrcpp::ws2s(tree->toStringTree(&parser)) << std::endl;
|
std::cout << antlrcpp::ws2s(tree->toStringTree(&parser)) << std::endl;
|
||||||
|
|
||||||
|
|
|
@ -105,10 +105,10 @@ using namespace antlrcpp;
|
||||||
delete a; delete b; delete c; delete d;
|
delete a; delete b; delete c; delete d;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::shared_ptr<A> a(new A());
|
Ref<A> a(new A());
|
||||||
std::shared_ptr<B> b(new B());
|
Ref<B> b(new B());
|
||||||
std::shared_ptr<C> c(new C());
|
Ref<C> c(new C());
|
||||||
std::shared_ptr<D> d(new D());
|
Ref<D> d(new D());
|
||||||
XCTAssert(is<A>(b));
|
XCTAssert(is<A>(b));
|
||||||
XCTAssertFalse(is<B>(a));
|
XCTAssertFalse(is<B>(a));
|
||||||
XCTAssert(is<A>(c));
|
XCTAssert(is<A>(c));
|
||||||
|
@ -136,7 +136,7 @@ using namespace antlrcpp;
|
||||||
hash = MurmurHash::finish(hash, data.size());
|
hash = MurmurHash::finish(hash, data.size());
|
||||||
hashs.insert(hash);
|
hashs.insert(hash);
|
||||||
}
|
}
|
||||||
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicat hash found.");
|
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
|
||||||
|
|
||||||
hashs.clear();
|
hashs.clear();
|
||||||
for (size_t i = 0; i < 100000; ++i) {
|
for (size_t i = 0; i < 100000; ++i) {
|
||||||
|
@ -147,7 +147,7 @@ using namespace antlrcpp;
|
||||||
hash = MurmurHash::finish(hash, data.size());
|
hash = MurmurHash::finish(hash, data.size());
|
||||||
hashs.insert(hash);
|
hashs.insert(hash);
|
||||||
}
|
}
|
||||||
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicat hash found.");
|
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
|
||||||
|
|
||||||
// Another test with fixed input but varying seeds.
|
// Another test with fixed input but varying seeds.
|
||||||
// Note: the higher the seed the less LSDs are in the result (for small input data).
|
// Note: the higher the seed the less LSDs are in the result (for small input data).
|
||||||
|
@ -160,7 +160,7 @@ using namespace antlrcpp;
|
||||||
hash = MurmurHash::finish(hash, data.size());
|
hash = MurmurHash::finish(hash, data.size());
|
||||||
hashs.insert(hash);
|
hashs.insert(hash);
|
||||||
}
|
}
|
||||||
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicat hash found.");
|
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testInterval {
|
- (void)testInterval {
|
||||||
|
|
|
@ -15,6 +15,14 @@
|
||||||
2747A70D1CA691310030247B /* ConfigLookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 2747A7091CA691310030247B /* ConfigLookup.h */; };
|
2747A70D1CA691310030247B /* ConfigLookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 2747A7091CA691310030247B /* ConfigLookup.h */; };
|
||||||
2747A7131CA6C46C0030247B /* InputHandlingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2747A7121CA6C46C0030247B /* InputHandlingTests.mm */; };
|
2747A7131CA6C46C0030247B /* InputHandlingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2747A7121CA6C46C0030247B /* InputHandlingTests.mm */; };
|
||||||
274FC6D91CA96B6C008D4374 /* MiscClassTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */; };
|
274FC6D91CA96B6C008D4374 /* MiscClassTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */; };
|
||||||
|
275411DE1CCE704300CAD5B0 /* LexerActionExecutor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275411DC1CCE704300CAD5B0 /* LexerActionExecutor.cpp */; };
|
||||||
|
275411DF1CCE704300CAD5B0 /* LexerActionExecutor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275411DC1CCE704300CAD5B0 /* LexerActionExecutor.cpp */; };
|
||||||
|
275411E01CCE704300CAD5B0 /* LexerActionExecutor.h in Headers */ = {isa = PBXBuildFile; fileRef = 275411DD1CCE704300CAD5B0 /* LexerActionExecutor.h */; };
|
||||||
|
275411E11CCE704300CAD5B0 /* LexerActionExecutor.h in Headers */ = {isa = PBXBuildFile; fileRef = 275411DD1CCE704300CAD5B0 /* LexerActionExecutor.h */; };
|
||||||
|
275411E41CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275411E21CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp */; };
|
||||||
|
275411E51CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275411E21CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp */; };
|
||||||
|
275411E61CCE733800CAD5B0 /* LexerIndexedCustomAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 275411E31CCE733800CAD5B0 /* LexerIndexedCustomAction.h */; };
|
||||||
|
275411E71CCE733800CAD5B0 /* LexerIndexedCustomAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 275411E31CCE733800CAD5B0 /* LexerIndexedCustomAction.h */; };
|
||||||
275DB3E41CCD23C000D8C543 /* LexerChannelAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275DB3D41CCD23C000D8C543 /* LexerChannelAction.cpp */; };
|
275DB3E41CCD23C000D8C543 /* LexerChannelAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275DB3D41CCD23C000D8C543 /* LexerChannelAction.cpp */; };
|
||||||
275DB3E51CCD23C000D8C543 /* LexerChannelAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 275DB3D51CCD23C000D8C543 /* LexerChannelAction.h */; };
|
275DB3E51CCD23C000D8C543 /* LexerChannelAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 275DB3D51CCD23C000D8C543 /* LexerChannelAction.h */; };
|
||||||
275DB3E61CCD23C000D8C543 /* LexerCustomAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275DB3D61CCD23C000D8C543 /* LexerCustomAction.cpp */; };
|
275DB3E61CCD23C000D8C543 /* LexerCustomAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275DB3D61CCD23C000D8C543 /* LexerCustomAction.cpp */; };
|
||||||
|
@ -49,6 +57,42 @@
|
||||||
278A66FC1C95838E002D667E /* ANTLRErrorListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 278A66FA1C95838E002D667E /* ANTLRErrorListener.cpp */; };
|
278A66FC1C95838E002D667E /* ANTLRErrorListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 278A66FA1C95838E002D667E /* ANTLRErrorListener.cpp */; };
|
||||||
27A23EA31CC2A8D60036D8A3 /* TLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */; };
|
27A23EA31CC2A8D60036D8A3 /* TLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */; };
|
||||||
27A23EA41CC2A8D60036D8A3 /* TLexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 27A23EA21CC2A8D60036D8A3 /* TLexer.h */; };
|
27A23EA41CC2A8D60036D8A3 /* TLexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 27A23EA21CC2A8D60036D8A3 /* TLexer.h */; };
|
||||||
|
27C62E261CD269C90088721B /* ParseInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E241CD269C90088721B /* ParseInfo.cpp */; };
|
||||||
|
27C62E271CD269C90088721B /* ParseInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E241CD269C90088721B /* ParseInfo.cpp */; };
|
||||||
|
27C62E281CD269C90088721B /* ParseInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E251CD269C90088721B /* ParseInfo.h */; };
|
||||||
|
27C62E291CD269C90088721B /* ParseInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E251CD269C90088721B /* ParseInfo.h */; };
|
||||||
|
27C62E2C1CD26C780088721B /* ProfilingATNSimulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E2A1CD26C780088721B /* ProfilingATNSimulator.cpp */; };
|
||||||
|
27C62E2D1CD26C780088721B /* ProfilingATNSimulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E2A1CD26C780088721B /* ProfilingATNSimulator.cpp */; };
|
||||||
|
27C62E2E1CD26C780088721B /* ProfilingATNSimulator.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E2B1CD26C780088721B /* ProfilingATNSimulator.h */; };
|
||||||
|
27C62E2F1CD26C780088721B /* ProfilingATNSimulator.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E2B1CD26C780088721B /* ProfilingATNSimulator.h */; };
|
||||||
|
27C62E321CD26EEA0088721B /* DecisionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E301CD26EEA0088721B /* DecisionInfo.cpp */; };
|
||||||
|
27C62E331CD26EEA0088721B /* DecisionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E301CD26EEA0088721B /* DecisionInfo.cpp */; };
|
||||||
|
27C62E341CD26EEA0088721B /* DecisionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E311CD26EEA0088721B /* DecisionInfo.h */; };
|
||||||
|
27C62E351CD26EEA0088721B /* DecisionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E311CD26EEA0088721B /* DecisionInfo.h */; };
|
||||||
|
27C62E381CD271C60088721B /* ErrorInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E361CD271C60088721B /* ErrorInfo.cpp */; };
|
||||||
|
27C62E391CD271C60088721B /* ErrorInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E361CD271C60088721B /* ErrorInfo.cpp */; };
|
||||||
|
27C62E3A1CD271C60088721B /* ErrorInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E371CD271C60088721B /* ErrorInfo.h */; };
|
||||||
|
27C62E3B1CD271C60088721B /* ErrorInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E371CD271C60088721B /* ErrorInfo.h */; };
|
||||||
|
27C62E3E1CD272480088721B /* DecisionEventInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E3C1CD272480088721B /* DecisionEventInfo.cpp */; };
|
||||||
|
27C62E3F1CD272480088721B /* DecisionEventInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E3C1CD272480088721B /* DecisionEventInfo.cpp */; };
|
||||||
|
27C62E401CD272480088721B /* DecisionEventInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E3D1CD272480088721B /* DecisionEventInfo.h */; };
|
||||||
|
27C62E411CD272480088721B /* DecisionEventInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E3D1CD272480088721B /* DecisionEventInfo.h */; };
|
||||||
|
27C62E441CD273DE0088721B /* LookaheadEventInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E421CD273DE0088721B /* LookaheadEventInfo.cpp */; };
|
||||||
|
27C62E451CD273DE0088721B /* LookaheadEventInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E421CD273DE0088721B /* LookaheadEventInfo.cpp */; };
|
||||||
|
27C62E461CD273DE0088721B /* LookaheadEventInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E431CD273DE0088721B /* LookaheadEventInfo.h */; };
|
||||||
|
27C62E471CD273DE0088721B /* LookaheadEventInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E431CD273DE0088721B /* LookaheadEventInfo.h */; };
|
||||||
|
27C62E4A1CD274CA0088721B /* AmbiguityInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E481CD274CA0088721B /* AmbiguityInfo.cpp */; };
|
||||||
|
27C62E4B1CD274CA0088721B /* AmbiguityInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E481CD274CA0088721B /* AmbiguityInfo.cpp */; };
|
||||||
|
27C62E4C1CD274CA0088721B /* AmbiguityInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E491CD274CA0088721B /* AmbiguityInfo.h */; };
|
||||||
|
27C62E4D1CD274CA0088721B /* AmbiguityInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E491CD274CA0088721B /* AmbiguityInfo.h */; };
|
||||||
|
27C62E501CD275C50088721B /* ContextSensitivityInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E4E1CD275C50088721B /* ContextSensitivityInfo.cpp */; };
|
||||||
|
27C62E511CD275C50088721B /* ContextSensitivityInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E4E1CD275C50088721B /* ContextSensitivityInfo.cpp */; };
|
||||||
|
27C62E521CD275C50088721B /* ContextSensitivityInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E4F1CD275C50088721B /* ContextSensitivityInfo.h */; };
|
||||||
|
27C62E531CD275C50088721B /* ContextSensitivityInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E4F1CD275C50088721B /* ContextSensitivityInfo.h */; };
|
||||||
|
27C62E561CD2768A0088721B /* PredicateEvalInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E541CD2768A0088721B /* PredicateEvalInfo.cpp */; };
|
||||||
|
27C62E571CD2768A0088721B /* PredicateEvalInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C62E541CD2768A0088721B /* PredicateEvalInfo.cpp */; };
|
||||||
|
27C62E581CD2768A0088721B /* PredicateEvalInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E551CD2768A0088721B /* PredicateEvalInfo.h */; };
|
||||||
|
27C62E591CD2768A0088721B /* PredicateEvalInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C62E551CD2768A0088721B /* PredicateEvalInfo.h */; };
|
||||||
27C666AC1C9584050021E494 /* ANTLRErrorListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C6665D1C9584050021E494 /* ANTLRErrorListener.h */; };
|
27C666AC1C9584050021E494 /* ANTLRErrorListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C6665D1C9584050021E494 /* ANTLRErrorListener.h */; };
|
||||||
27C666AD1C9584050021E494 /* ANTLRErrorListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C6665D1C9584050021E494 /* ANTLRErrorListener.h */; };
|
27C666AD1C9584050021E494 /* ANTLRErrorListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C6665D1C9584050021E494 /* ANTLRErrorListener.h */; };
|
||||||
27C666AE1C9584050021E494 /* ANTLRErrorStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6665E1C9584050021E494 /* ANTLRErrorStrategy.cpp */; };
|
27C666AE1C9584050021E494 /* ANTLRErrorStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6665E1C9584050021E494 /* ANTLRErrorStrategy.cpp */; };
|
||||||
|
@ -532,6 +576,12 @@
|
||||||
27C6E1821C972FFC0079AF06 /* TParserBaseVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */; };
|
27C6E1821C972FFC0079AF06 /* TParserBaseVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */; };
|
||||||
27C6E1831C972FFC0079AF06 /* TParserListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */; };
|
27C6E1831C972FFC0079AF06 /* TParserListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */; };
|
||||||
27C6E1841C972FFC0079AF06 /* TParserVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */; };
|
27C6E1841C972FFC0079AF06 /* TParserVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */; };
|
||||||
|
27C7D08A1CD10D1900F7E81F /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C7D0851CD10D1900F7E81F /* Vocabulary.h */; };
|
||||||
|
27C7D08B1CD10D1900F7E81F /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C7D0851CD10D1900F7E81F /* Vocabulary.h */; };
|
||||||
|
27C7D08C1CD10D1900F7E81F /* VocabularyImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C7D0861CD10D1900F7E81F /* VocabularyImpl.cpp */; };
|
||||||
|
27C7D08D1CD10D1900F7E81F /* VocabularyImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C7D0861CD10D1900F7E81F /* VocabularyImpl.cpp */; };
|
||||||
|
27C7D08E1CD10D1900F7E81F /* VocabularyImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C7D0871CD10D1900F7E81F /* VocabularyImpl.h */; };
|
||||||
|
27C7D08F1CD10D1900F7E81F /* VocabularyImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 27C7D0871CD10D1900F7E81F /* VocabularyImpl.h */; };
|
||||||
37F1356D1B4AC02800E0CACF /* antlrcpp_Tests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */; };
|
37F1356D1B4AC02800E0CACF /* antlrcpp_Tests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */; };
|
||||||
37F1356E1B4AC02800E0CACF /* antlrcpp.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 37D727AA1867AF1E007B6D10 /* antlrcpp.dylib */; };
|
37F1356E1B4AC02800E0CACF /* antlrcpp.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 37D727AA1867AF1E007B6D10 /* antlrcpp.dylib */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
@ -570,6 +620,10 @@
|
||||||
2747A7091CA691310030247B /* ConfigLookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConfigLookup.h; sourceTree = "<group>"; wrapsLines = 0; };
|
2747A7091CA691310030247B /* ConfigLookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConfigLookup.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
2747A7121CA6C46C0030247B /* InputHandlingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InputHandlingTests.mm; sourceTree = "<group>"; wrapsLines = 0; };
|
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; };
|
274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MiscClassTests.mm; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
275411DC1CCE704300CAD5B0 /* LexerActionExecutor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerActionExecutor.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
275411DD1CCE704300CAD5B0 /* LexerActionExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerActionExecutor.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
275411E21CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerIndexedCustomAction.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
275411E31CCE733800CAD5B0 /* LexerIndexedCustomAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerIndexedCustomAction.h; sourceTree = "<group>"; };
|
||||||
275DB3D41CCD23C000D8C543 /* LexerChannelAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerChannelAction.cpp; sourceTree = "<group>"; };
|
275DB3D41CCD23C000D8C543 /* LexerChannelAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerChannelAction.cpp; sourceTree = "<group>"; };
|
||||||
275DB3D51CCD23C000D8C543 /* LexerChannelAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerChannelAction.h; sourceTree = "<group>"; };
|
275DB3D51CCD23C000D8C543 /* LexerChannelAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerChannelAction.h; sourceTree = "<group>"; };
|
||||||
275DB3D61CCD23C000D8C543 /* LexerCustomAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerCustomAction.cpp; sourceTree = "<group>"; };
|
275DB3D61CCD23C000D8C543 /* LexerCustomAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerCustomAction.cpp; sourceTree = "<group>"; };
|
||||||
|
@ -595,6 +649,24 @@
|
||||||
278A66FA1C95838E002D667E /* ANTLRErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ANTLRErrorListener.cpp; path = ../../runtime/ANTLRErrorListener.cpp; sourceTree = SOURCE_ROOT; };
|
278A66FA1C95838E002D667E /* ANTLRErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ANTLRErrorListener.cpp; path = ../../runtime/ANTLRErrorListener.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TLexer.cpp; path = ../generated/TLexer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
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>"; };
|
27A23EA21CC2A8D60036D8A3 /* TLexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TLexer.h; path = ../generated/TLexer.h; sourceTree = "<group>"; };
|
||||||
|
27C62E241CD269C90088721B /* ParseInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParseInfo.cpp; sourceTree = "<group>"; };
|
||||||
|
27C62E251CD269C90088721B /* ParseInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseInfo.h; sourceTree = "<group>"; };
|
||||||
|
27C62E2A1CD26C780088721B /* ProfilingATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProfilingATNSimulator.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E2B1CD26C780088721B /* ProfilingATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfilingATNSimulator.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E301CD26EEA0088721B /* DecisionInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecisionInfo.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E311CD26EEA0088721B /* DecisionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecisionInfo.h; sourceTree = "<group>"; };
|
||||||
|
27C62E361CD271C60088721B /* ErrorInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorInfo.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E371CD271C60088721B /* ErrorInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorInfo.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E3C1CD272480088721B /* DecisionEventInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecisionEventInfo.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E3D1CD272480088721B /* DecisionEventInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecisionEventInfo.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E421CD273DE0088721B /* LookaheadEventInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LookaheadEventInfo.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E431CD273DE0088721B /* LookaheadEventInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LookaheadEventInfo.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E481CD274CA0088721B /* AmbiguityInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AmbiguityInfo.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E491CD274CA0088721B /* AmbiguityInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AmbiguityInfo.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E4E1CD275C50088721B /* ContextSensitivityInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContextSensitivityInfo.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E4F1CD275C50088721B /* ContextSensitivityInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextSensitivityInfo.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E541CD2768A0088721B /* PredicateEvalInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PredicateEvalInfo.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C62E551CD2768A0088721B /* PredicateEvalInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PredicateEvalInfo.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
27C6665D1C9584050021E494 /* ANTLRErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ANTLRErrorListener.h; path = ../../runtime/ANTLRErrorListener.h; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C6665D1C9584050021E494 /* ANTLRErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ANTLRErrorListener.h; path = ../../runtime/ANTLRErrorListener.h; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C6665E1C9584050021E494 /* ANTLRErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ANTLRErrorStrategy.cpp; path = ../../runtime/ANTLRErrorStrategy.cpp; sourceTree = SOURCE_ROOT; };
|
27C6665E1C9584050021E494 /* ANTLRErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ANTLRErrorStrategy.cpp; path = ../../runtime/ANTLRErrorStrategy.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
27C6665F1C9584050021E494 /* ANTLRErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ANTLRErrorStrategy.h; path = ../../runtime/ANTLRErrorStrategy.h; sourceTree = SOURCE_ROOT; };
|
27C6665F1C9584050021E494 /* ANTLRErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ANTLRErrorStrategy.h; path = ../../runtime/ANTLRErrorStrategy.h; sourceTree = SOURCE_ROOT; };
|
||||||
|
@ -617,7 +689,7 @@
|
||||||
27C666701C9584050021E494 /* CommonTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommonTokenStream.cpp; path = ../../runtime/CommonTokenStream.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C666701C9584050021E494 /* CommonTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommonTokenStream.cpp; path = ../../runtime/CommonTokenStream.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C666711C9584050021E494 /* CommonTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommonTokenStream.h; path = ../../runtime/CommonTokenStream.h; sourceTree = SOURCE_ROOT; };
|
27C666711C9584050021E494 /* CommonTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommonTokenStream.h; path = ../../runtime/CommonTokenStream.h; sourceTree = SOURCE_ROOT; };
|
||||||
27C666721C9584050021E494 /* ConsoleErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConsoleErrorListener.cpp; path = ../../runtime/ConsoleErrorListener.cpp; sourceTree = SOURCE_ROOT; };
|
27C666721C9584050021E494 /* ConsoleErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConsoleErrorListener.cpp; path = ../../runtime/ConsoleErrorListener.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
27C666731C9584050021E494 /* ConsoleErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConsoleErrorListener.h; path = ../../runtime/ConsoleErrorListener.h; sourceTree = SOURCE_ROOT; };
|
27C666731C9584050021E494 /* ConsoleErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConsoleErrorListener.h; path = ../../runtime/ConsoleErrorListener.h; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C666741C9584050021E494 /* DefaultErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DefaultErrorStrategy.cpp; path = ../../runtime/DefaultErrorStrategy.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C666741C9584050021E494 /* DefaultErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DefaultErrorStrategy.cpp; path = ../../runtime/DefaultErrorStrategy.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C666751C9584050021E494 /* DefaultErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DefaultErrorStrategy.h; path = ../../runtime/DefaultErrorStrategy.h; sourceTree = SOURCE_ROOT; };
|
27C666751C9584050021E494 /* DefaultErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DefaultErrorStrategy.h; path = ../../runtime/DefaultErrorStrategy.h; sourceTree = SOURCE_ROOT; };
|
||||||
27C666761C9584050021E494 /* DiagnosticErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DiagnosticErrorListener.cpp; path = ../../runtime/DiagnosticErrorListener.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C666761C9584050021E494 /* DiagnosticErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DiagnosticErrorListener.cpp; path = ../../runtime/DiagnosticErrorListener.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
|
@ -654,7 +726,7 @@
|
||||||
27C666961C9584050021E494 /* RecognitionException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecognitionException.cpp; path = ../../runtime/RecognitionException.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C666961C9584050021E494 /* RecognitionException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecognitionException.cpp; path = ../../runtime/RecognitionException.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C666971C9584050021E494 /* RecognitionException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecognitionException.h; path = ../../runtime/RecognitionException.h; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C666971C9584050021E494 /* RecognitionException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecognitionException.h; path = ../../runtime/RecognitionException.h; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C666981C9584050021E494 /* Recognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Recognizer.h; path = ../../runtime/Recognizer.h; sourceTree = SOURCE_ROOT; };
|
27C666981C9584050021E494 /* Recognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Recognizer.h; path = ../../runtime/Recognizer.h; sourceTree = SOURCE_ROOT; };
|
||||||
27C666991C9584050021E494 /* Recognizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Recognizer.cpp; path = ../../runtime/Recognizer.cpp; sourceTree = SOURCE_ROOT; };
|
27C666991C9584050021E494 /* Recognizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Recognizer.cpp; path = ../../runtime/Recognizer.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C6669A1C9584050021E494 /* RuleContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RuleContext.cpp; path = ../../runtime/RuleContext.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C6669A1C9584050021E494 /* RuleContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RuleContext.cpp; path = ../../runtime/RuleContext.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
27C6669B1C9584050021E494 /* RuleContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RuleContext.h; path = ../../runtime/RuleContext.h; sourceTree = SOURCE_ROOT; };
|
27C6669B1C9584050021E494 /* RuleContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RuleContext.h; path = ../../runtime/RuleContext.h; sourceTree = SOURCE_ROOT; };
|
||||||
27C6669C1C9584050021E494 /* Token.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Token.cpp; path = ../../runtime/Token.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
27C6669C1C9584050021E494 /* Token.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Token.cpp; path = ../../runtime/Token.cpp; sourceTree = SOURCE_ROOT; wrapsLines = 0; };
|
||||||
|
@ -714,7 +786,7 @@
|
||||||
27C6676D1C95846E0021E494 /* EpsilonTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EpsilonTransition.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
27C6676D1C95846E0021E494 /* EpsilonTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EpsilonTransition.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
27C6676E1C95846E0021E494 /* EpsilonTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EpsilonTransition.h; sourceTree = "<group>"; };
|
27C6676E1C95846E0021E494 /* EpsilonTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EpsilonTransition.h; sourceTree = "<group>"; };
|
||||||
27C6676F1C95846E0021E494 /* LexerATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNConfig.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
27C6676F1C95846E0021E494 /* LexerATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNConfig.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
27C667701C95846E0021E494 /* LexerATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNConfig.h; sourceTree = "<group>"; };
|
27C667701C95846E0021E494 /* LexerATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNConfig.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
27C667711C95846E0021E494 /* LexerATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNSimulator.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
27C667711C95846E0021E494 /* LexerATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNSimulator.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
27C667721C95846E0021E494 /* LexerATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNSimulator.h; sourceTree = "<group>"; wrapsLines = 0; };
|
27C667721C95846E0021E494 /* LexerATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNSimulator.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
27C667731C95846E0021E494 /* LL1Analyzer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LL1Analyzer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
27C667731C95846E0021E494 /* LL1Analyzer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LL1Analyzer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
@ -849,6 +921,9 @@
|
||||||
27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserVisitor.cpp; path = ../generated/TParserVisitor.cpp; 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; };
|
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>"; };
|
27C6E1861C97322F0079AF06 /* TParserVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserVisitor.h; path = ../generated/TParserVisitor.h; sourceTree = "<group>"; };
|
||||||
|
27C7D0851CD10D1900F7E81F /* Vocabulary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vocabulary.h; sourceTree = "<group>"; };
|
||||||
|
27C7D0861CD10D1900F7E81F /* VocabularyImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VocabularyImpl.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
|
27C7D0871CD10D1900F7E81F /* VocabularyImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VocabularyImpl.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||||
37C147171B4D5A04008EDDDB /* libantlrcpp_static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libantlrcpp_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
37C147171B4D5A04008EDDDB /* libantlrcpp_static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libantlrcpp_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
37D727AA1867AF1E007B6D10 /* antlrcpp.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = antlrcpp.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
37D727AA1867AF1E007B6D10 /* antlrcpp.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = antlrcpp.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "antlrcpp Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "antlrcpp Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
@ -907,6 +982,8 @@
|
||||||
27C667481C95846E0021E494 /* AbstractPredicateTransition.h */,
|
27C667481C95846E0021E494 /* AbstractPredicateTransition.h */,
|
||||||
27C667491C95846E0021E494 /* ActionTransition.cpp */,
|
27C667491C95846E0021E494 /* ActionTransition.cpp */,
|
||||||
27C6674A1C95846E0021E494 /* ActionTransition.h */,
|
27C6674A1C95846E0021E494 /* ActionTransition.h */,
|
||||||
|
27C62E481CD274CA0088721B /* AmbiguityInfo.cpp */,
|
||||||
|
27C62E491CD274CA0088721B /* AmbiguityInfo.h */,
|
||||||
27C6674B1C95846E0021E494 /* ArrayPredictionContext.cpp */,
|
27C6674B1C95846E0021E494 /* ArrayPredictionContext.cpp */,
|
||||||
27C6674C1C95846E0021E494 /* ArrayPredictionContext.h */,
|
27C6674C1C95846E0021E494 /* ArrayPredictionContext.h */,
|
||||||
27C6674D1C95846E0021E494 /* ATN.cpp */,
|
27C6674D1C95846E0021E494 /* ATN.cpp */,
|
||||||
|
@ -939,14 +1016,24 @@
|
||||||
27C667681C95846E0021E494 /* BlockStartState.h */,
|
27C667681C95846E0021E494 /* BlockStartState.h */,
|
||||||
2747A7081CA691310030247B /* ConfigLookup.cpp */,
|
2747A7081CA691310030247B /* ConfigLookup.cpp */,
|
||||||
2747A7091CA691310030247B /* ConfigLookup.h */,
|
2747A7091CA691310030247B /* ConfigLookup.h */,
|
||||||
|
27C62E4E1CD275C50088721B /* ContextSensitivityInfo.cpp */,
|
||||||
|
27C62E4F1CD275C50088721B /* ContextSensitivityInfo.h */,
|
||||||
|
27C62E3C1CD272480088721B /* DecisionEventInfo.cpp */,
|
||||||
|
27C62E3D1CD272480088721B /* DecisionEventInfo.h */,
|
||||||
|
27C62E301CD26EEA0088721B /* DecisionInfo.cpp */,
|
||||||
|
27C62E311CD26EEA0088721B /* DecisionInfo.h */,
|
||||||
27C667691C95846E0021E494 /* DecisionState.cpp */,
|
27C667691C95846E0021E494 /* DecisionState.cpp */,
|
||||||
27C6676A1C95846E0021E494 /* DecisionState.h */,
|
27C6676A1C95846E0021E494 /* DecisionState.h */,
|
||||||
27C6676B1C95846E0021E494 /* EmptyPredictionContext.cpp */,
|
27C6676B1C95846E0021E494 /* EmptyPredictionContext.cpp */,
|
||||||
27C6676C1C95846E0021E494 /* EmptyPredictionContext.h */,
|
27C6676C1C95846E0021E494 /* EmptyPredictionContext.h */,
|
||||||
27C6676D1C95846E0021E494 /* EpsilonTransition.cpp */,
|
27C6676D1C95846E0021E494 /* EpsilonTransition.cpp */,
|
||||||
27C6676E1C95846E0021E494 /* EpsilonTransition.h */,
|
27C6676E1C95846E0021E494 /* EpsilonTransition.h */,
|
||||||
|
27C62E361CD271C60088721B /* ErrorInfo.cpp */,
|
||||||
|
27C62E371CD271C60088721B /* ErrorInfo.h */,
|
||||||
275ECC4A1CCCD95B00E79E2A /* LexerAction.cpp */,
|
275ECC4A1CCCD95B00E79E2A /* LexerAction.cpp */,
|
||||||
275ECC4B1CCCD95B00E79E2A /* LexerAction.h */,
|
275ECC4B1CCCD95B00E79E2A /* LexerAction.h */,
|
||||||
|
275411DC1CCE704300CAD5B0 /* LexerActionExecutor.cpp */,
|
||||||
|
275411DD1CCE704300CAD5B0 /* LexerActionExecutor.h */,
|
||||||
275ECC501CCCD9FB00E79E2A /* LexerActionType.cpp */,
|
275ECC501CCCD9FB00E79E2A /* LexerActionType.cpp */,
|
||||||
275ECC511CCCD9FB00E79E2A /* LexerActionType.h */,
|
275ECC511CCCD9FB00E79E2A /* LexerActionType.h */,
|
||||||
27C6676F1C95846E0021E494 /* LexerATNConfig.cpp */,
|
27C6676F1C95846E0021E494 /* LexerATNConfig.cpp */,
|
||||||
|
@ -957,6 +1044,8 @@
|
||||||
275DB3D51CCD23C000D8C543 /* LexerChannelAction.h */,
|
275DB3D51CCD23C000D8C543 /* LexerChannelAction.h */,
|
||||||
275DB3D61CCD23C000D8C543 /* LexerCustomAction.cpp */,
|
275DB3D61CCD23C000D8C543 /* LexerCustomAction.cpp */,
|
||||||
275DB3D71CCD23C000D8C543 /* LexerCustomAction.h */,
|
275DB3D71CCD23C000D8C543 /* LexerCustomAction.h */,
|
||||||
|
275411E21CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp */,
|
||||||
|
275411E31CCE733800CAD5B0 /* LexerIndexedCustomAction.h */,
|
||||||
275DB3D81CCD23C000D8C543 /* LexerModeAction.cpp */,
|
275DB3D81CCD23C000D8C543 /* LexerModeAction.cpp */,
|
||||||
275DB3D91CCD23C000D8C543 /* LexerModeAction.h */,
|
275DB3D91CCD23C000D8C543 /* LexerModeAction.h */,
|
||||||
275DB3DA1CCD23C000D8C543 /* LexerMoreAction.cpp */,
|
275DB3DA1CCD23C000D8C543 /* LexerMoreAction.cpp */,
|
||||||
|
@ -971,12 +1060,16 @@
|
||||||
275DB3E31CCD23C000D8C543 /* LexerTypeAction.h */,
|
275DB3E31CCD23C000D8C543 /* LexerTypeAction.h */,
|
||||||
27C667731C95846E0021E494 /* LL1Analyzer.cpp */,
|
27C667731C95846E0021E494 /* LL1Analyzer.cpp */,
|
||||||
27C667741C95846E0021E494 /* LL1Analyzer.h */,
|
27C667741C95846E0021E494 /* LL1Analyzer.h */,
|
||||||
|
27C62E421CD273DE0088721B /* LookaheadEventInfo.cpp */,
|
||||||
|
27C62E431CD273DE0088721B /* LookaheadEventInfo.h */,
|
||||||
27C667751C95846E0021E494 /* LoopEndState.cpp */,
|
27C667751C95846E0021E494 /* LoopEndState.cpp */,
|
||||||
27C667761C95846E0021E494 /* LoopEndState.h */,
|
27C667761C95846E0021E494 /* LoopEndState.h */,
|
||||||
27C667781C95846E0021E494 /* NotSetTransition.cpp */,
|
27C667781C95846E0021E494 /* NotSetTransition.cpp */,
|
||||||
27C667791C95846E0021E494 /* NotSetTransition.h */,
|
27C667791C95846E0021E494 /* NotSetTransition.h */,
|
||||||
27C6677A1C95846E0021E494 /* OrderedATNConfigSet.cpp */,
|
27C6677A1C95846E0021E494 /* OrderedATNConfigSet.cpp */,
|
||||||
27C6677B1C95846E0021E494 /* OrderedATNConfigSet.h */,
|
27C6677B1C95846E0021E494 /* OrderedATNConfigSet.h */,
|
||||||
|
27C62E241CD269C90088721B /* ParseInfo.cpp */,
|
||||||
|
27C62E251CD269C90088721B /* ParseInfo.h */,
|
||||||
27C6677C1C95846E0021E494 /* ParserATNSimulator.cpp */,
|
27C6677C1C95846E0021E494 /* ParserATNSimulator.cpp */,
|
||||||
27C6677D1C95846E0021E494 /* ParserATNSimulator.h */,
|
27C6677D1C95846E0021E494 /* ParserATNSimulator.h */,
|
||||||
27C6677E1C95846E0021E494 /* PlusBlockStartState.cpp */,
|
27C6677E1C95846E0021E494 /* PlusBlockStartState.cpp */,
|
||||||
|
@ -985,12 +1078,16 @@
|
||||||
27C667811C95846E0021E494 /* PlusLoopbackState.h */,
|
27C667811C95846E0021E494 /* PlusLoopbackState.h */,
|
||||||
27C667821C95846E0021E494 /* PrecedencePredicateTransition.cpp */,
|
27C667821C95846E0021E494 /* PrecedencePredicateTransition.cpp */,
|
||||||
27C667831C95846E0021E494 /* PrecedencePredicateTransition.h */,
|
27C667831C95846E0021E494 /* PrecedencePredicateTransition.h */,
|
||||||
|
27C62E541CD2768A0088721B /* PredicateEvalInfo.cpp */,
|
||||||
|
27C62E551CD2768A0088721B /* PredicateEvalInfo.h */,
|
||||||
27C667841C95846E0021E494 /* PredicateTransition.cpp */,
|
27C667841C95846E0021E494 /* PredicateTransition.cpp */,
|
||||||
27C667851C95846E0021E494 /* PredicateTransition.h */,
|
27C667851C95846E0021E494 /* PredicateTransition.h */,
|
||||||
27C667861C95846E0021E494 /* PredictionContext.cpp */,
|
27C667861C95846E0021E494 /* PredictionContext.cpp */,
|
||||||
27C667871C95846E0021E494 /* PredictionContext.h */,
|
27C667871C95846E0021E494 /* PredictionContext.h */,
|
||||||
27C6678A1C95846E0021E494 /* PredictionMode.cpp */,
|
27C6678A1C95846E0021E494 /* PredictionMode.cpp */,
|
||||||
27C6678B1C95846E0021E494 /* PredictionMode.h */,
|
27C6678B1C95846E0021E494 /* PredictionMode.h */,
|
||||||
|
27C62E2A1CD26C780088721B /* ProfilingATNSimulator.cpp */,
|
||||||
|
27C62E2B1CD26C780088721B /* ProfilingATNSimulator.h */,
|
||||||
27C6678C1C95846E0021E494 /* RangeTransition.cpp */,
|
27C6678C1C95846E0021E494 /* RangeTransition.cpp */,
|
||||||
27C6678D1C95846E0021E494 /* RangeTransition.h */,
|
27C6678D1C95846E0021E494 /* RangeTransition.h */,
|
||||||
27C6678E1C95846E0021E494 /* RuleStartState.cpp */,
|
27C6678E1C95846E0021E494 /* RuleStartState.cpp */,
|
||||||
|
@ -1223,8 +1320,8 @@
|
||||||
27C666951C9584050021E494 /* ProxyErrorListener.h */,
|
27C666951C9584050021E494 /* ProxyErrorListener.h */,
|
||||||
27C666961C9584050021E494 /* RecognitionException.cpp */,
|
27C666961C9584050021E494 /* RecognitionException.cpp */,
|
||||||
27C666971C9584050021E494 /* RecognitionException.h */,
|
27C666971C9584050021E494 /* RecognitionException.h */,
|
||||||
27C666981C9584050021E494 /* Recognizer.h */,
|
|
||||||
27C666991C9584050021E494 /* Recognizer.cpp */,
|
27C666991C9584050021E494 /* Recognizer.cpp */,
|
||||||
|
27C666981C9584050021E494 /* Recognizer.h */,
|
||||||
27C6669A1C9584050021E494 /* RuleContext.cpp */,
|
27C6669A1C9584050021E494 /* RuleContext.cpp */,
|
||||||
27C6669B1C9584050021E494 /* RuleContext.h */,
|
27C6669B1C9584050021E494 /* RuleContext.h */,
|
||||||
27C6669C1C9584050021E494 /* Token.cpp */,
|
27C6669C1C9584050021E494 /* Token.cpp */,
|
||||||
|
@ -1239,8 +1336,11 @@
|
||||||
27C666A51C9584050021E494 /* TokenStreamRewriter.h */,
|
27C666A51C9584050021E494 /* TokenStreamRewriter.h */,
|
||||||
27C666A61C9584050021E494 /* UnbufferedCharStream.cpp */,
|
27C666A61C9584050021E494 /* UnbufferedCharStream.cpp */,
|
||||||
27C666A71C9584050021E494 /* UnbufferedCharStream.h */,
|
27C666A71C9584050021E494 /* UnbufferedCharStream.h */,
|
||||||
27C666A81C9584050021E494 /* UnbufferedTokenStream.h */,
|
|
||||||
27C666A91C9584050021E494 /* UnbufferedTokenStream.cpp */,
|
27C666A91C9584050021E494 /* UnbufferedTokenStream.cpp */,
|
||||||
|
27C666A81C9584050021E494 /* UnbufferedTokenStream.h */,
|
||||||
|
27C7D0851CD10D1900F7E81F /* Vocabulary.h */,
|
||||||
|
27C7D0861CD10D1900F7E81F /* VocabularyImpl.cpp */,
|
||||||
|
27C7D0871CD10D1900F7E81F /* VocabularyImpl.h */,
|
||||||
27C666AA1C9584050021E494 /* WritableToken.cpp */,
|
27C666AA1C9584050021E494 /* WritableToken.cpp */,
|
||||||
27C666AB1C9584050021E494 /* WritableToken.h */,
|
27C666AB1C9584050021E494 /* WritableToken.h */,
|
||||||
);
|
);
|
||||||
|
@ -1301,6 +1401,7 @@
|
||||||
27C668431C95846E0021E494 /* SemanticContext.h in Headers */,
|
27C668431C95846E0021E494 /* SemanticContext.h in Headers */,
|
||||||
27C667B51C95846E0021E494 /* ATN.h in Headers */,
|
27C667B51C95846E0021E494 /* ATN.h in Headers */,
|
||||||
27C668471C95846E0021E494 /* SetTransition.h in Headers */,
|
27C668471C95846E0021E494 /* SetTransition.h in Headers */,
|
||||||
|
27C62E411CD272480088721B /* DecisionEventInfo.h in Headers */,
|
||||||
27C667DD1C95846E0021E494 /* BasicBlockStartState.h in Headers */,
|
27C667DD1C95846E0021E494 /* BasicBlockStartState.h in Headers */,
|
||||||
27C667111C9584050021E494 /* Parser.h in Headers */,
|
27C667111C9584050021E494 /* Parser.h in Headers */,
|
||||||
27C6684B1C95846E0021E494 /* SingletonPredictionContext.h in Headers */,
|
27C6684B1C95846E0021E494 /* SingletonPredictionContext.h in Headers */,
|
||||||
|
@ -1319,6 +1420,7 @@
|
||||||
27C667D11C95846E0021E494 /* ATNState.h in Headers */,
|
27C667D11C95846E0021E494 /* ATNState.h in Headers */,
|
||||||
27C6672B1C9584050021E494 /* Token.h in Headers */,
|
27C6672B1C9584050021E494 /* Token.h in Headers */,
|
||||||
27C667151C9584050021E494 /* ParserInterpreter.h in Headers */,
|
27C667151C9584050021E494 /* ParserInterpreter.h in Headers */,
|
||||||
|
27C62E531CD275C50088721B /* ContextSensitivityInfo.h in Headers */,
|
||||||
27C667C51C95846E0021E494 /* ATNDeserializer.h in Headers */,
|
27C667C51C95846E0021E494 /* ATNDeserializer.h in Headers */,
|
||||||
27C66A1D1C958AB30021E494 /* TextChunk.h in Headers */,
|
27C66A1D1C958AB30021E494 /* TextChunk.h in Headers */,
|
||||||
27C667CD1C95846E0021E494 /* ATNSimulator.h in Headers */,
|
27C667CD1C95846E0021E494 /* ATNSimulator.h in Headers */,
|
||||||
|
@ -1337,15 +1439,18 @@
|
||||||
27C667371C9584050021E494 /* TokenStream.h in Headers */,
|
27C667371C9584050021E494 /* TokenStream.h in Headers */,
|
||||||
27C6682F1C95846E0021E494 /* PredictionMode.h in Headers */,
|
27C6682F1C95846E0021E494 /* PredictionMode.h in Headers */,
|
||||||
27C669A61C9585B80021E494 /* ParseTreeVisitor.h in Headers */,
|
27C669A61C9585B80021E494 /* ParseTreeVisitor.h in Headers */,
|
||||||
|
27C7D08B1CD10D1900F7E81F /* Vocabulary.h in Headers */,
|
||||||
27C668741C9584B60021E494 /* DFASerializer.h in Headers */,
|
27C668741C9584B60021E494 /* DFASerializer.h in Headers */,
|
||||||
27C669961C9585B80021E494 /* ErrorNodeImpl.h in Headers */,
|
27C669961C9585B80021E494 /* ErrorNodeImpl.h in Headers */,
|
||||||
27C667C91C95846E0021E494 /* ATNSerializer.h in Headers */,
|
27C667C91C95846E0021E494 /* ATNSerializer.h in Headers */,
|
||||||
27C66A191C958AB30021E494 /* RuleTagToken.h in Headers */,
|
27C66A191C958AB30021E494 /* RuleTagToken.h in Headers */,
|
||||||
27C667411C9584050021E494 /* UnbufferedTokenStream.h in Headers */,
|
27C667411C9584050021E494 /* UnbufferedTokenStream.h in Headers */,
|
||||||
|
27C62E291CD269C90088721B /* ParseInfo.h in Headers */,
|
||||||
27C668131C95846E0021E494 /* ParserATNSimulator.h in Headers */,
|
27C668131C95846E0021E494 /* ParserATNSimulator.h in Headers */,
|
||||||
27C667051C9584050021E494 /* LexerNoViableAltException.h in Headers */,
|
27C667051C9584050021E494 /* LexerNoViableAltException.h in Headers */,
|
||||||
27C666B51C9584050021E494 /* ANTLRFileStream.h in Headers */,
|
27C666B51C9584050021E494 /* ANTLRFileStream.h in Headers */,
|
||||||
27C667B11C95846E0021E494 /* ArrayPredictionContext.h in Headers */,
|
27C667B11C95846E0021E494 /* ArrayPredictionContext.h in Headers */,
|
||||||
|
27C62E591CD2768A0088721B /* PredicateEvalInfo.h in Headers */,
|
||||||
2747A70D1CA691310030247B /* ConfigLookup.h in Headers */,
|
2747A70D1CA691310030247B /* ConfigLookup.h in Headers */,
|
||||||
27C669AE1C9585B80021E494 /* RuleNode.h in Headers */,
|
27C669AE1C9585B80021E494 /* RuleNode.h in Headers */,
|
||||||
27C667211C9584050021E494 /* RecognitionException.h in Headers */,
|
27C667211C9584050021E494 /* RecognitionException.h in Headers */,
|
||||||
|
@ -1364,14 +1469,17 @@
|
||||||
27C666D51C9584050021E494 /* CommonTokenStream.h in Headers */,
|
27C666D51C9584050021E494 /* CommonTokenStream.h in Headers */,
|
||||||
27C6681F1C95846E0021E494 /* PrecedencePredicateTransition.h in Headers */,
|
27C6681F1C95846E0021E494 /* PrecedencePredicateTransition.h in Headers */,
|
||||||
27C669BE1C9585B80021E494 /* Tree.h in Headers */,
|
27C669BE1C9585B80021E494 /* Tree.h in Headers */,
|
||||||
|
27C62E351CD26EEA0088721B /* DecisionInfo.h in Headers */,
|
||||||
27C667091C9584050021E494 /* ListTokenSource.h in Headers */,
|
27C667091C9584050021E494 /* ListTokenSource.h in Headers */,
|
||||||
27C669B21C9585B80021E494 /* SyntaxTree.h in Headers */,
|
27C669B21C9585B80021E494 /* SyntaxTree.h in Headers */,
|
||||||
|
27C62E2F1CD26C780088721B /* ProfilingATNSimulator.h in Headers */,
|
||||||
27C666C91C9584050021E494 /* CharStream.h in Headers */,
|
27C666C91C9584050021E494 /* CharStream.h in Headers */,
|
||||||
27C6671D1C9584050021E494 /* ProxyErrorListener.h in Headers */,
|
27C6671D1C9584050021E494 /* ProxyErrorListener.h in Headers */,
|
||||||
275ECC4F1CCCD95B00E79E2A /* LexerAction.h in Headers */,
|
275ECC4F1CCCD95B00E79E2A /* LexerAction.h in Headers */,
|
||||||
27C666E51C9584050021E494 /* Exceptions.h in Headers */,
|
27C666E51C9584050021E494 /* Exceptions.h in Headers */,
|
||||||
27C668B51C9584FA0021E494 /* Interval.h in Headers */,
|
27C668B51C9584FA0021E494 /* Interval.h in Headers */,
|
||||||
27C667E11C95846E0021E494 /* BasicState.h in Headers */,
|
27C667E11C95846E0021E494 /* BasicState.h in Headers */,
|
||||||
|
275411E71CCE733800CAD5B0 /* LexerIndexedCustomAction.h in Headers */,
|
||||||
27C666B91C9584050021E494 /* ANTLRInputStream.h in Headers */,
|
27C666B91C9584050021E494 /* ANTLRInputStream.h in Headers */,
|
||||||
27C6680F1C95846E0021E494 /* OrderedATNConfigSet.h in Headers */,
|
27C6680F1C95846E0021E494 /* OrderedATNConfigSet.h in Headers */,
|
||||||
27C666B11C9584050021E494 /* ANTLRErrorStrategy.h in Headers */,
|
27C666B11C9584050021E494 /* ANTLRErrorStrategy.h in Headers */,
|
||||||
|
@ -1383,11 +1491,13 @@
|
||||||
27C6683B1C95846E0021E494 /* RuleStopState.h in Headers */,
|
27C6683B1C95846E0021E494 /* RuleStopState.h in Headers */,
|
||||||
27C668781C9584B60021E494 /* DFAState.h in Headers */,
|
27C668781C9584B60021E494 /* DFAState.h in Headers */,
|
||||||
27C66A131C958AB30021E494 /* ParseTreeMatch.h in Headers */,
|
27C66A131C958AB30021E494 /* ParseTreeMatch.h in Headers */,
|
||||||
|
27C62E4D1CD274CA0088721B /* AmbiguityInfo.h in Headers */,
|
||||||
27C66A151C958AB30021E494 /* ParseTreePattern.h in Headers */,
|
27C66A151C958AB30021E494 /* ParseTreePattern.h in Headers */,
|
||||||
27C667ED1C95846E0021E494 /* DecisionState.h in Headers */,
|
27C667ED1C95846E0021E494 /* DecisionState.h in Headers */,
|
||||||
27C667FD1C95846E0021E494 /* LexerATNSimulator.h in Headers */,
|
27C667FD1C95846E0021E494 /* LexerATNSimulator.h in Headers */,
|
||||||
27C668571C95846E0021E494 /* StarLoopEntryState.h in Headers */,
|
27C668571C95846E0021E494 /* StarLoopEntryState.h in Headers */,
|
||||||
275ECC551CCCD9FB00E79E2A /* LexerActionType.h in Headers */,
|
275ECC551CCCD9FB00E79E2A /* LexerActionType.h in Headers */,
|
||||||
|
27C62E3B1CD271C60088721B /* ErrorInfo.h in Headers */,
|
||||||
27C6683F1C95846E0021E494 /* RuleTransition.h in Headers */,
|
27C6683F1C95846E0021E494 /* RuleTransition.h in Headers */,
|
||||||
27C667231C9584050021E494 /* Recognizer.h in Headers */,
|
27C667231C9584050021E494 /* Recognizer.h in Headers */,
|
||||||
27C667F11C95846E0021E494 /* EmptyPredictionContext.h in Headers */,
|
27C667F11C95846E0021E494 /* EmptyPredictionContext.h in Headers */,
|
||||||
|
@ -1411,11 +1521,14 @@
|
||||||
27C667011C9584050021E494 /* LexerInterpreter.h in Headers */,
|
27C667011C9584050021E494 /* LexerInterpreter.h in Headers */,
|
||||||
27C668701C9584B60021E494 /* DFA.h in Headers */,
|
27C668701C9584B60021E494 /* DFA.h in Headers */,
|
||||||
27C666D11C9584050021E494 /* CommonTokenFactory.h in Headers */,
|
27C666D11C9584050021E494 /* CommonTokenFactory.h in Headers */,
|
||||||
|
27C62E471CD273DE0088721B /* LookaheadEventInfo.h in Headers */,
|
||||||
27C6680B1C95846E0021E494 /* NotSetTransition.h in Headers */,
|
27C6680B1C95846E0021E494 /* NotSetTransition.h in Headers */,
|
||||||
27C667E91C95846E0021E494 /* BlockStartState.h in Headers */,
|
27C667E91C95846E0021E494 /* BlockStartState.h in Headers */,
|
||||||
27C666F91C9584050021E494 /* IRecognizer.h in Headers */,
|
27C666F91C9584050021E494 /* IRecognizer.h in Headers */,
|
||||||
276927251C9ED49100E4EBF8 /* antlrcpp-Prefix.h in Headers */,
|
276927251C9ED49100E4EBF8 /* antlrcpp-Prefix.h in Headers */,
|
||||||
27C669A21C9585B80021E494 /* ParseTreeProperty.h in Headers */,
|
27C669A21C9585B80021E494 /* ParseTreeProperty.h in Headers */,
|
||||||
|
27C7D08F1CD10D1900F7E81F /* VocabularyImpl.h in Headers */,
|
||||||
|
275411E11CCE704300CAD5B0 /* LexerActionExecutor.h in Headers */,
|
||||||
27C667A91C95846E0021E494 /* AbstractPredicateTransition.h in Headers */,
|
27C667A91C95846E0021E494 /* AbstractPredicateTransition.h in Headers */,
|
||||||
27C669171C9585230021E494 /* guid.h in Headers */,
|
27C669171C9585230021E494 /* guid.h in Headers */,
|
||||||
27C66A111C958AB30021E494 /* Chunk.h in Headers */,
|
27C66A111C958AB30021E494 /* Chunk.h in Headers */,
|
||||||
|
@ -1439,10 +1552,13 @@
|
||||||
27C667DC1C95846E0021E494 /* BasicBlockStartState.h in Headers */,
|
27C667DC1C95846E0021E494 /* BasicBlockStartState.h in Headers */,
|
||||||
27C666F81C9584050021E494 /* IRecognizer.h in Headers */,
|
27C666F81C9584050021E494 /* IRecognizer.h in Headers */,
|
||||||
27C667E01C95846E0021E494 /* BasicState.h in Headers */,
|
27C667E01C95846E0021E494 /* BasicState.h in Headers */,
|
||||||
|
27C62E281CD269C90088721B /* ParseInfo.h in Headers */,
|
||||||
27C666C01C9584050021E494 /* BaseErrorListener.h in Headers */,
|
27C666C01C9584050021E494 /* BaseErrorListener.h in Headers */,
|
||||||
|
27C62E2E1CD26C780088721B /* ProfilingATNSimulator.h in Headers */,
|
||||||
27C668421C95846E0021E494 /* SemanticContext.h in Headers */,
|
27C668421C95846E0021E494 /* SemanticContext.h in Headers */,
|
||||||
27C6682E1C95846E0021E494 /* PredictionMode.h in Headers */,
|
27C6682E1C95846E0021E494 /* PredictionMode.h in Headers */,
|
||||||
27C667261C9584050021E494 /* RuleContext.h in Headers */,
|
27C667261C9584050021E494 /* RuleContext.h in Headers */,
|
||||||
|
27C62E4C1CD274CA0088721B /* AmbiguityInfo.h in Headers */,
|
||||||
27C6672A1C9584050021E494 /* Token.h in Headers */,
|
27C6672A1C9584050021E494 /* Token.h in Headers */,
|
||||||
27C666B01C9584050021E494 /* ANTLRErrorStrategy.h in Headers */,
|
27C666B01C9584050021E494 /* ANTLRErrorStrategy.h in Headers */,
|
||||||
27C667201C9584050021E494 /* RecognitionException.h in Headers */,
|
27C667201C9584050021E494 /* RecognitionException.h in Headers */,
|
||||||
|
@ -1450,6 +1566,7 @@
|
||||||
27C6670C1C9584050021E494 /* NoViableAltException.h in Headers */,
|
27C6670C1C9584050021E494 /* NoViableAltException.h in Headers */,
|
||||||
27C6683A1C95846E0021E494 /* RuleStopState.h in Headers */,
|
27C6683A1C95846E0021E494 /* RuleStopState.h in Headers */,
|
||||||
27C666BC1C9584050021E494 /* BailErrorStrategy.h in Headers */,
|
27C666BC1C9584050021E494 /* BailErrorStrategy.h in Headers */,
|
||||||
|
27C62E401CD272480088721B /* DecisionEventInfo.h in Headers */,
|
||||||
27C66A1C1C958AB30021E494 /* TextChunk.h in Headers */,
|
27C66A1C1C958AB30021E494 /* TextChunk.h in Headers */,
|
||||||
27C667EC1C95846E0021E494 /* DecisionState.h in Headers */,
|
27C667EC1C95846E0021E494 /* DecisionState.h in Headers */,
|
||||||
27C667001C9584050021E494 /* LexerInterpreter.h in Headers */,
|
27C667001C9584050021E494 /* LexerInterpreter.h in Headers */,
|
||||||
|
@ -1467,10 +1584,12 @@
|
||||||
27C6684E1C95846E0021E494 /* StarBlockStartState.h in Headers */,
|
27C6684E1C95846E0021E494 /* StarBlockStartState.h in Headers */,
|
||||||
27C668221C95846E0021E494 /* PredicateTransition.h in Headers */,
|
27C668221C95846E0021E494 /* PredicateTransition.h in Headers */,
|
||||||
27C6698D1C9585B80021E494 /* AbstractParseTreeVisitor.h in Headers */,
|
27C6698D1C9585B80021E494 /* AbstractParseTreeVisitor.h in Headers */,
|
||||||
|
275411E61CCE733800CAD5B0 /* LexerIndexedCustomAction.h in Headers */,
|
||||||
27C668621C95846E0021E494 /* WildcardTransition.h in Headers */,
|
27C668621C95846E0021E494 /* WildcardTransition.h in Headers */,
|
||||||
27C66A181C958AB30021E494 /* RuleTagToken.h in Headers */,
|
27C66A181C958AB30021E494 /* RuleTagToken.h in Headers */,
|
||||||
27C668B81C9584FA0021E494 /* IntervalSet.h in Headers */,
|
27C668B81C9584FA0021E494 /* IntervalSet.h in Headers */,
|
||||||
27C668261C95846E0021E494 /* PredictionContext.h in Headers */,
|
27C668261C95846E0021E494 /* PredictionContext.h in Headers */,
|
||||||
|
275411E01CCE704300CAD5B0 /* LexerActionExecutor.h in Headers */,
|
||||||
27C669B11C9585B80021E494 /* SyntaxTree.h in Headers */,
|
27C669B11C9585B80021E494 /* SyntaxTree.h in Headers */,
|
||||||
275DB3F31CCD23C000D8C543 /* LexerTypeAction.h in Headers */,
|
275DB3F31CCD23C000D8C543 /* LexerTypeAction.h in Headers */,
|
||||||
27C666D01C9584050021E494 /* CommonTokenFactory.h in Headers */,
|
27C666D01C9584050021E494 /* CommonTokenFactory.h in Headers */,
|
||||||
|
@ -1495,16 +1614,19 @@
|
||||||
27C6687B1C9584B60021E494 /* LexerDFASerializer.h in Headers */,
|
27C6687B1C9584B60021E494 /* LexerDFASerializer.h in Headers */,
|
||||||
27C668001C95846E0021E494 /* LL1Analyzer.h in Headers */,
|
27C668001C95846E0021E494 /* LL1Analyzer.h in Headers */,
|
||||||
27C667141C9584050021E494 /* ParserInterpreter.h in Headers */,
|
27C667141C9584050021E494 /* ParserInterpreter.h in Headers */,
|
||||||
|
27C7D08E1CD10D1900F7E81F /* VocabularyImpl.h in Headers */,
|
||||||
27C6673A1C9584050021E494 /* TokenStreamRewriter.h in Headers */,
|
27C6673A1C9584050021E494 /* TokenStreamRewriter.h in Headers */,
|
||||||
27C6684A1C95846E0021E494 /* SingletonPredictionContext.h in Headers */,
|
27C6684A1C95846E0021E494 /* SingletonPredictionContext.h in Headers */,
|
||||||
27C667041C9584050021E494 /* LexerNoViableAltException.h in Headers */,
|
27C667041C9584050021E494 /* LexerNoViableAltException.h in Headers */,
|
||||||
27C669121C9585230021E494 /* Strings.h in Headers */,
|
27C669121C9585230021E494 /* Strings.h in Headers */,
|
||||||
275DB3E51CCD23C000D8C543 /* LexerChannelAction.h in Headers */,
|
275DB3E51CCD23C000D8C543 /* LexerChannelAction.h in Headers */,
|
||||||
27C667E41C95846E0021E494 /* BlockEndState.h in Headers */,
|
27C667E41C95846E0021E494 /* BlockEndState.h in Headers */,
|
||||||
|
27C7D08A1CD10D1900F7E81F /* Vocabulary.h in Headers */,
|
||||||
27C666B41C9584050021E494 /* ANTLRFileStream.h in Headers */,
|
27C666B41C9584050021E494 /* ANTLRFileStream.h in Headers */,
|
||||||
27C6685E1C95846E0021E494 /* Transition.h in Headers */,
|
27C6685E1C95846E0021E494 /* Transition.h in Headers */,
|
||||||
275ECC541CCCD9FB00E79E2A /* LexerActionType.h in Headers */,
|
275ECC541CCCD9FB00E79E2A /* LexerActionType.h in Headers */,
|
||||||
27C666CC1C9584050021E494 /* CommonToken.h in Headers */,
|
27C666CC1C9584050021E494 /* CommonToken.h in Headers */,
|
||||||
|
27C62E581CD2768A0088721B /* PredicateEvalInfo.h in Headers */,
|
||||||
27C6699D1C9585B80021E494 /* ParseTreeListener.h in Headers */,
|
27C6699D1C9585B80021E494 /* ParseTreeListener.h in Headers */,
|
||||||
27C666F61C9584050021E494 /* IntStream.h in Headers */,
|
27C666F61C9584050021E494 /* IntStream.h in Headers */,
|
||||||
27C669951C9585B80021E494 /* ErrorNodeImpl.h in Headers */,
|
27C669951C9585B80021E494 /* ErrorNodeImpl.h in Headers */,
|
||||||
|
@ -1531,9 +1653,11 @@
|
||||||
27C666C81C9584050021E494 /* CharStream.h in Headers */,
|
27C666C81C9584050021E494 /* CharStream.h in Headers */,
|
||||||
27C668041C95846E0021E494 /* LoopEndState.h in Headers */,
|
27C668041C95846E0021E494 /* LoopEndState.h in Headers */,
|
||||||
27C6685A1C95846E0021E494 /* TokensStartState.h in Headers */,
|
27C6685A1C95846E0021E494 /* TokensStartState.h in Headers */,
|
||||||
|
27C62E3A1CD271C60088721B /* ErrorInfo.h in Headers */,
|
||||||
27C668561C95846E0021E494 /* StarLoopEntryState.h in Headers */,
|
27C668561C95846E0021E494 /* StarLoopEntryState.h in Headers */,
|
||||||
27C667B41C95846E0021E494 /* ATN.h in Headers */,
|
27C667B41C95846E0021E494 /* ATN.h in Headers */,
|
||||||
275DB3ED1CCD23C000D8C543 /* LexerPopModeAction.h in Headers */,
|
275DB3ED1CCD23C000D8C543 /* LexerPopModeAction.h in Headers */,
|
||||||
|
27C62E521CD275C50088721B /* ContextSensitivityInfo.h in Headers */,
|
||||||
27C669AD1C9585B80021E494 /* RuleNode.h in Headers */,
|
27C669AD1C9585B80021E494 /* RuleNode.h in Headers */,
|
||||||
27C668771C9584B60021E494 /* DFAState.h in Headers */,
|
27C668771C9584B60021E494 /* DFAState.h in Headers */,
|
||||||
27C6680A1C95846E0021E494 /* NotSetTransition.h in Headers */,
|
27C6680A1C95846E0021E494 /* NotSetTransition.h in Headers */,
|
||||||
|
@ -1546,6 +1670,7 @@
|
||||||
27C669BD1C9585B80021E494 /* Tree.h in Headers */,
|
27C669BD1C9585B80021E494 /* Tree.h in Headers */,
|
||||||
27C668161C95846E0021E494 /* PlusBlockStartState.h in Headers */,
|
27C668161C95846E0021E494 /* PlusBlockStartState.h in Headers */,
|
||||||
27C667D01C95846E0021E494 /* ATNState.h in Headers */,
|
27C667D01C95846E0021E494 /* ATNState.h in Headers */,
|
||||||
|
27C62E461CD273DE0088721B /* LookaheadEventInfo.h in Headers */,
|
||||||
27C667FC1C95846E0021E494 /* LexerATNSimulator.h in Headers */,
|
27C667FC1C95846E0021E494 /* LexerATNSimulator.h in Headers */,
|
||||||
27C669A11C9585B80021E494 /* ParseTreeProperty.h in Headers */,
|
27C669A11C9585B80021E494 /* ParseTreeProperty.h in Headers */,
|
||||||
27C667F01C95846E0021E494 /* EmptyPredictionContext.h in Headers */,
|
27C667F01C95846E0021E494 /* EmptyPredictionContext.h in Headers */,
|
||||||
|
@ -1565,6 +1690,7 @@
|
||||||
27C667B81C95846E0021E494 /* ATNConfig.h in Headers */,
|
27C667B81C95846E0021E494 /* ATNConfig.h in Headers */,
|
||||||
27C667B01C95846E0021E494 /* ArrayPredictionContext.h in Headers */,
|
27C667B01C95846E0021E494 /* ArrayPredictionContext.h in Headers */,
|
||||||
27C669021C9585230021E494 /* BitSet.h in Headers */,
|
27C669021C9585230021E494 /* BitSet.h in Headers */,
|
||||||
|
27C62E341CD26EEA0088721B /* DecisionInfo.h in Headers */,
|
||||||
27C66A1E1C958AB30021E494 /* TokenTagToken.h in Headers */,
|
27C66A1E1C958AB30021E494 /* TokenTagToken.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -1732,12 +1858,14 @@
|
||||||
27C668B71C9584FA0021E494 /* IntervalSet.cpp in Sources */,
|
27C668B71C9584FA0021E494 /* IntervalSet.cpp in Sources */,
|
||||||
27C668251C95846E0021E494 /* PredictionContext.cpp in Sources */,
|
27C668251C95846E0021E494 /* PredictionContext.cpp in Sources */,
|
||||||
27C668491C95846E0021E494 /* SingletonPredictionContext.cpp in Sources */,
|
27C668491C95846E0021E494 /* SingletonPredictionContext.cpp in Sources */,
|
||||||
|
27C62E2D1CD26C780088721B /* ProfilingATNSimulator.cpp in Sources */,
|
||||||
27C667BF1C95846E0021E494 /* ATNDeserializationOptions.cpp in Sources */,
|
27C667BF1C95846E0021E494 /* ATNDeserializationOptions.cpp in Sources */,
|
||||||
27C667CF1C95846E0021E494 /* ATNState.cpp in Sources */,
|
27C667CF1C95846E0021E494 /* ATNState.cpp in Sources */,
|
||||||
27C667AF1C95846E0021E494 /* ArrayPredictionContext.cpp in Sources */,
|
27C667AF1C95846E0021E494 /* ArrayPredictionContext.cpp in Sources */,
|
||||||
27C669981C9585B80021E494 /* ParseTree.cpp in Sources */,
|
27C669981C9585B80021E494 /* ParseTree.cpp in Sources */,
|
||||||
27C6698C1C9585B80021E494 /* AbstractParseTreeVisitor.cpp in Sources */,
|
27C6698C1C9585B80021E494 /* AbstractParseTreeVisitor.cpp in Sources */,
|
||||||
27C669C01C9585B80021E494 /* Trees.cpp in Sources */,
|
27C669C01C9585B80021E494 /* Trees.cpp in Sources */,
|
||||||
|
27C62E271CD269C90088721B /* ParseInfo.cpp in Sources */,
|
||||||
278A66FC1C95838E002D667E /* ANTLRErrorListener.cpp in Sources */,
|
278A66FC1C95838E002D667E /* ANTLRErrorListener.cpp in Sources */,
|
||||||
27C668391C95846E0021E494 /* RuleStopState.cpp in Sources */,
|
27C668391C95846E0021E494 /* RuleStopState.cpp in Sources */,
|
||||||
27C669AC1C9585B80021E494 /* RuleNode.cpp in Sources */,
|
27C669AC1C9585B80021E494 /* RuleNode.cpp in Sources */,
|
||||||
|
@ -1746,6 +1874,7 @@
|
||||||
27C668551C95846E0021E494 /* StarLoopEntryState.cpp in Sources */,
|
27C668551C95846E0021E494 /* StarLoopEntryState.cpp in Sources */,
|
||||||
27C668761C9584B60021E494 /* DFAState.cpp in Sources */,
|
27C668761C9584B60021E494 /* DFAState.cpp in Sources */,
|
||||||
27C667B71C95846E0021E494 /* ATNConfig.cpp in Sources */,
|
27C667B71C95846E0021E494 /* ATNConfig.cpp in Sources */,
|
||||||
|
27C62E391CD271C60088721B /* ErrorInfo.cpp in Sources */,
|
||||||
27C668611C95846E0021E494 /* WildcardTransition.cpp in Sources */,
|
27C668611C95846E0021E494 /* WildcardTransition.cpp in Sources */,
|
||||||
27C667DF1C95846E0021E494 /* BasicState.cpp in Sources */,
|
27C667DF1C95846E0021E494 /* BasicState.cpp in Sources */,
|
||||||
27C6670B1C9584050021E494 /* NoViableAltException.cpp in Sources */,
|
27C6670B1C9584050021E494 /* NoViableAltException.cpp in Sources */,
|
||||||
|
@ -1760,10 +1889,13 @@
|
||||||
27C668B31C9584FA0021E494 /* Interval.cpp in Sources */,
|
27C668B31C9584FA0021E494 /* Interval.cpp in Sources */,
|
||||||
27C6682D1C95846E0021E494 /* PredictionMode.cpp in Sources */,
|
27C6682D1C95846E0021E494 /* PredictionMode.cpp in Sources */,
|
||||||
27C666D31C9584050021E494 /* CommonTokenStream.cpp in Sources */,
|
27C666D31C9584050021E494 /* CommonTokenStream.cpp in Sources */,
|
||||||
|
27C62E3F1CD272480088721B /* DecisionEventInfo.cpp in Sources */,
|
||||||
27C667311C9584050021E494 /* TokenSource.cpp in Sources */,
|
27C667311C9584050021E494 /* TokenSource.cpp in Sources */,
|
||||||
27C668CB1C9584FA0021E494 /* MurmurHash.cpp in Sources */,
|
27C668CB1C9584FA0021E494 /* MurmurHash.cpp in Sources */,
|
||||||
27C669A81C9585B80021E494 /* ParseTreeWalker.cpp in Sources */,
|
27C669A81C9585B80021E494 /* ParseTreeWalker.cpp in Sources */,
|
||||||
|
27C62E511CD275C50088721B /* ContextSensitivityInfo.cpp in Sources */,
|
||||||
27C666ED1C9584050021E494 /* InputMismatchException.cpp in Sources */,
|
27C666ED1C9584050021E494 /* InputMismatchException.cpp in Sources */,
|
||||||
|
275411E51CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp in Sources */,
|
||||||
27C668031C95846E0021E494 /* LoopEndState.cpp in Sources */,
|
27C668031C95846E0021E494 /* LoopEndState.cpp in Sources */,
|
||||||
27C666B31C9584050021E494 /* ANTLRFileStream.cpp in Sources */,
|
27C666B31C9584050021E494 /* ANTLRFileStream.cpp in Sources */,
|
||||||
27C669111C9585230021E494 /* Strings.cpp in Sources */,
|
27C669111C9585230021E494 /* Strings.cpp in Sources */,
|
||||||
|
@ -1779,11 +1911,14 @@
|
||||||
27C669151C9585230021E494 /* guid.cpp in Sources */,
|
27C669151C9585230021E494 /* guid.cpp in Sources */,
|
||||||
27C669941C9585B80021E494 /* ErrorNodeImpl.cpp in Sources */,
|
27C669941C9585B80021E494 /* ErrorNodeImpl.cpp in Sources */,
|
||||||
27C6687A1C9584B60021E494 /* LexerDFASerializer.cpp in Sources */,
|
27C6687A1C9584B60021E494 /* LexerDFASerializer.cpp in Sources */,
|
||||||
|
27C7D08D1CD10D1900F7E81F /* VocabularyImpl.cpp in Sources */,
|
||||||
27C6685D1C95846E0021E494 /* Transition.cpp in Sources */,
|
27C6685D1C95846E0021E494 /* Transition.cpp in Sources */,
|
||||||
|
27C62E4B1CD274CA0088721B /* AmbiguityInfo.cpp in Sources */,
|
||||||
27C667351C9584050021E494 /* TokenStream.cpp in Sources */,
|
27C667351C9584050021E494 /* TokenStream.cpp in Sources */,
|
||||||
27C666F51C9584050021E494 /* IntStream.cpp in Sources */,
|
27C666F51C9584050021E494 /* IntStream.cpp in Sources */,
|
||||||
27C669B01C9585B80021E494 /* SyntaxTree.cpp in Sources */,
|
27C669B01C9585B80021E494 /* SyntaxTree.cpp in Sources */,
|
||||||
27C667071C9584050021E494 /* ListTokenSource.cpp in Sources */,
|
27C667071C9584050021E494 /* ListTokenSource.cpp in Sources */,
|
||||||
|
27C62E331CD26EEA0088721B /* DecisionInfo.cpp in Sources */,
|
||||||
27C6681D1C95846E0021E494 /* PrecedencePredicateTransition.cpp in Sources */,
|
27C6681D1C95846E0021E494 /* PrecedencePredicateTransition.cpp in Sources */,
|
||||||
27C66A0F1C958AB30021E494 /* TokenTagToken.cpp in Sources */,
|
27C66A0F1C958AB30021E494 /* TokenTagToken.cpp in Sources */,
|
||||||
276901AA1CAD7E67005CEC6A /* Recognizer.cpp in Sources */,
|
276901AA1CAD7E67005CEC6A /* Recognizer.cpp in Sources */,
|
||||||
|
@ -1801,6 +1936,7 @@
|
||||||
27C666D71C9584050021E494 /* ConsoleErrorListener.cpp in Sources */,
|
27C666D71C9584050021E494 /* ConsoleErrorListener.cpp in Sources */,
|
||||||
27C666FB1C9584050021E494 /* Lexer.cpp in Sources */,
|
27C666FB1C9584050021E494 /* Lexer.cpp in Sources */,
|
||||||
27C668351C95846E0021E494 /* RuleStartState.cpp in Sources */,
|
27C668351C95846E0021E494 /* RuleStartState.cpp in Sources */,
|
||||||
|
27C62E451CD273DE0088721B /* LookaheadEventInfo.cpp in Sources */,
|
||||||
27C66A0B1C958AB30021E494 /* TagChunk.cpp in Sources */,
|
27C66A0B1C958AB30021E494 /* TagChunk.cpp in Sources */,
|
||||||
272415E51CB54C09007E056A /* UnbufferedTokenStream.cpp in Sources */,
|
272415E51CB54C09007E056A /* UnbufferedTokenStream.cpp in Sources */,
|
||||||
27C666FF1C9584050021E494 /* LexerInterpreter.cpp in Sources */,
|
27C666FF1C9584050021E494 /* LexerInterpreter.cpp in Sources */,
|
||||||
|
@ -1808,6 +1944,7 @@
|
||||||
27C6673D1C9584050021E494 /* UnbufferedCharStream.cpp in Sources */,
|
27C6673D1C9584050021E494 /* UnbufferedCharStream.cpp in Sources */,
|
||||||
27C667D31C95846E0021E494 /* ATNType.cpp in Sources */,
|
27C667D31C95846E0021E494 /* ATNType.cpp in Sources */,
|
||||||
27C669B41C9585B80021E494 /* TerminalNode.cpp in Sources */,
|
27C669B41C9585B80021E494 /* TerminalNode.cpp in Sources */,
|
||||||
|
27C62E571CD2768A0088721B /* PredicateEvalInfo.cpp in Sources */,
|
||||||
27C666C31C9584050021E494 /* BufferedTokenStream.cpp in Sources */,
|
27C666C31C9584050021E494 /* BufferedTokenStream.cpp in Sources */,
|
||||||
27C666B71C9584050021E494 /* ANTLRInputStream.cpp in Sources */,
|
27C666B71C9584050021E494 /* ANTLRInputStream.cpp in Sources */,
|
||||||
27C668211C95846E0021E494 /* PredicateTransition.cpp in Sources */,
|
27C668211C95846E0021E494 /* PredicateTransition.cpp in Sources */,
|
||||||
|
@ -1833,6 +1970,7 @@
|
||||||
27C66A0D1C958AB30021E494 /* TextChunk.cpp in Sources */,
|
27C66A0D1C958AB30021E494 /* TextChunk.cpp in Sources */,
|
||||||
27C669BC1C9585B80021E494 /* Tree.cpp in Sources */,
|
27C669BC1C9585B80021E494 /* Tree.cpp in Sources */,
|
||||||
27C6670F1C9584050021E494 /* Parser.cpp in Sources */,
|
27C6670F1C9584050021E494 /* Parser.cpp in Sources */,
|
||||||
|
275411DF1CCE704300CAD5B0 /* LexerActionExecutor.cpp in Sources */,
|
||||||
27C669A01C9585B80021E494 /* ParseTreeProperty.cpp in Sources */,
|
27C669A01C9585B80021E494 /* ParseTreeProperty.cpp in Sources */,
|
||||||
27C668451C95846E0021E494 /* SetTransition.cpp in Sources */,
|
27C668451C95846E0021E494 /* SetTransition.cpp in Sources */,
|
||||||
27C667BB1C95846E0021E494 /* ATNConfigSet.cpp in Sources */,
|
27C667BB1C95846E0021E494 /* ATNConfigSet.cpp in Sources */,
|
||||||
|
@ -1858,6 +1996,7 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
27C62E261CD269C90088721B /* ParseInfo.cpp in Sources */,
|
||||||
27C668241C95846E0021E494 /* PredictionContext.cpp in Sources */,
|
27C668241C95846E0021E494 /* PredictionContext.cpp in Sources */,
|
||||||
27C666E61C9584050021E494 /* FailedPredicateException.cpp in Sources */,
|
27C666E61C9584050021E494 /* FailedPredicateException.cpp in Sources */,
|
||||||
275DB3EE1CCD23C000D8C543 /* LexerPushModeAction.cpp in Sources */,
|
275DB3EE1CCD23C000D8C543 /* LexerPushModeAction.cpp in Sources */,
|
||||||
|
@ -1873,17 +2012,22 @@
|
||||||
27C6670A1C9584050021E494 /* NoViableAltException.cpp in Sources */,
|
27C6670A1C9584050021E494 /* NoViableAltException.cpp in Sources */,
|
||||||
27C667161C9584050021E494 /* ParserRuleContext.cpp in Sources */,
|
27C667161C9584050021E494 /* ParserRuleContext.cpp in Sources */,
|
||||||
27C669BF1C9585B80021E494 /* Trees.cpp in Sources */,
|
27C669BF1C9585B80021E494 /* Trees.cpp in Sources */,
|
||||||
|
27C62E381CD271C60088721B /* ErrorInfo.cpp in Sources */,
|
||||||
27C666B61C9584050021E494 /* ANTLRInputStream.cpp in Sources */,
|
27C666B61C9584050021E494 /* ANTLRInputStream.cpp in Sources */,
|
||||||
|
27C62E561CD2768A0088721B /* PredicateEvalInfo.cpp in Sources */,
|
||||||
27C666F41C9584050021E494 /* IntStream.cpp in Sources */,
|
27C666F41C9584050021E494 /* IntStream.cpp in Sources */,
|
||||||
27C667D61C95846E0021E494 /* AtomTransition.cpp in Sources */,
|
27C667D61C95846E0021E494 /* AtomTransition.cpp in Sources */,
|
||||||
27C667E21C95846E0021E494 /* BlockEndState.cpp in Sources */,
|
27C667E21C95846E0021E494 /* BlockEndState.cpp in Sources */,
|
||||||
|
27C62E4A1CD274CA0088721B /* AmbiguityInfo.cpp in Sources */,
|
||||||
27C669BB1C9585B80021E494 /* Tree.cpp in Sources */,
|
27C669BB1C9585B80021E494 /* Tree.cpp in Sources */,
|
||||||
27C6673C1C9584050021E494 /* UnbufferedCharStream.cpp in Sources */,
|
27C6673C1C9584050021E494 /* UnbufferedCharStream.cpp in Sources */,
|
||||||
27C6698B1C9585B80021E494 /* AbstractParseTreeVisitor.cpp in Sources */,
|
27C6698B1C9585B80021E494 /* AbstractParseTreeVisitor.cpp in Sources */,
|
||||||
|
27C62E321CD26EEA0088721B /* DecisionInfo.cpp in Sources */,
|
||||||
27C666D61C9584050021E494 /* ConsoleErrorListener.cpp in Sources */,
|
27C666D61C9584050021E494 /* ConsoleErrorListener.cpp in Sources */,
|
||||||
27C668381C95846E0021E494 /* RuleStopState.cpp in Sources */,
|
27C668381C95846E0021E494 /* RuleStopState.cpp in Sources */,
|
||||||
27C6680C1C95846E0021E494 /* OrderedATNConfigSet.cpp in Sources */,
|
27C6680C1C95846E0021E494 /* OrderedATNConfigSet.cpp in Sources */,
|
||||||
275ECC4C1CCCD95B00E79E2A /* LexerAction.cpp in Sources */,
|
275ECC4C1CCCD95B00E79E2A /* LexerAction.cpp in Sources */,
|
||||||
|
27C62E441CD273DE0088721B /* LookaheadEventInfo.cpp in Sources */,
|
||||||
275DB3F21CCD23C000D8C543 /* LexerTypeAction.cpp in Sources */,
|
275DB3F21CCD23C000D8C543 /* LexerTypeAction.cpp in Sources */,
|
||||||
27C667BA1C95846E0021E494 /* ATNConfigSet.cpp in Sources */,
|
27C667BA1C95846E0021E494 /* ATNConfigSet.cpp in Sources */,
|
||||||
275DB3EC1CCD23C000D8C543 /* LexerPopModeAction.cpp in Sources */,
|
275DB3EC1CCD23C000D8C543 /* LexerPopModeAction.cpp in Sources */,
|
||||||
|
@ -1923,6 +2067,7 @@
|
||||||
27C669AF1C9585B80021E494 /* SyntaxTree.cpp in Sources */,
|
27C669AF1C9585B80021E494 /* SyntaxTree.cpp in Sources */,
|
||||||
27C667DA1C95846E0021E494 /* BasicBlockStartState.cpp in Sources */,
|
27C667DA1C95846E0021E494 /* BasicBlockStartState.cpp in Sources */,
|
||||||
27C666AE1C9584050021E494 /* ANTLRErrorStrategy.cpp in Sources */,
|
27C666AE1C9584050021E494 /* ANTLRErrorStrategy.cpp in Sources */,
|
||||||
|
275411DE1CCE704300CAD5B0 /* LexerActionExecutor.cpp in Sources */,
|
||||||
27C667EA1C95846E0021E494 /* DecisionState.cpp in Sources */,
|
27C667EA1C95846E0021E494 /* DecisionState.cpp in Sources */,
|
||||||
27C666FE1C9584050021E494 /* LexerInterpreter.cpp in Sources */,
|
27C666FE1C9584050021E494 /* LexerInterpreter.cpp in Sources */,
|
||||||
27C666CE1C9584050021E494 /* CommonTokenFactory.cpp in Sources */,
|
27C666CE1C9584050021E494 /* CommonTokenFactory.cpp in Sources */,
|
||||||
|
@ -1938,6 +2083,8 @@
|
||||||
27C667AE1C95846E0021E494 /* ArrayPredictionContext.cpp in Sources */,
|
27C667AE1C95846E0021E494 /* ArrayPredictionContext.cpp in Sources */,
|
||||||
27C669041C9585230021E494 /* CPPUtils.cpp in Sources */,
|
27C669041C9585230021E494 /* CPPUtils.cpp in Sources */,
|
||||||
272415E41CB54C08007E056A /* UnbufferedTokenStream.cpp in Sources */,
|
272415E41CB54C08007E056A /* UnbufferedTokenStream.cpp in Sources */,
|
||||||
|
275411E41CCE733800CAD5B0 /* LexerIndexedCustomAction.cpp in Sources */,
|
||||||
|
27C62E3E1CD272480088721B /* DecisionEventInfo.cpp in Sources */,
|
||||||
27C667021C9584050021E494 /* LexerNoViableAltException.cpp in Sources */,
|
27C667021C9584050021E494 /* LexerNoViableAltException.cpp in Sources */,
|
||||||
27C667EE1C95846E0021E494 /* EmptyPredictionContext.cpp in Sources */,
|
27C667EE1C95846E0021E494 /* EmptyPredictionContext.cpp in Sources */,
|
||||||
27C666C61C9584050021E494 /* CharStream.cpp in Sources */,
|
27C666C61C9584050021E494 /* CharStream.cpp in Sources */,
|
||||||
|
@ -1949,7 +2096,9 @@
|
||||||
27C667E61C95846E0021E494 /* BlockStartState.cpp in Sources */,
|
27C667E61C95846E0021E494 /* BlockStartState.cpp in Sources */,
|
||||||
27C668DE1C9584FA0021E494 /* TestRig.cpp in Sources */,
|
27C668DE1C9584FA0021E494 /* TestRig.cpp in Sources */,
|
||||||
27C666D21C9584050021E494 /* CommonTokenStream.cpp in Sources */,
|
27C666D21C9584050021E494 /* CommonTokenStream.cpp in Sources */,
|
||||||
|
27C62E501CD275C50088721B /* ContextSensitivityInfo.cpp in Sources */,
|
||||||
27C669A71C9585B80021E494 /* ParseTreeWalker.cpp in Sources */,
|
27C669A71C9585B80021E494 /* ParseTreeWalker.cpp in Sources */,
|
||||||
|
27C62E2C1CD26C780088721B /* ProfilingATNSimulator.cpp in Sources */,
|
||||||
27C669B71C9585B80021E494 /* TerminalNodeImpl.cpp in Sources */,
|
27C669B71C9585B80021E494 /* TerminalNodeImpl.cpp in Sources */,
|
||||||
27C667C21C95846E0021E494 /* ATNDeserializer.cpp in Sources */,
|
27C667C21C95846E0021E494 /* ATNDeserializer.cpp in Sources */,
|
||||||
27C668301C95846E0021E494 /* RangeTransition.cpp in Sources */,
|
27C668301C95846E0021E494 /* RangeTransition.cpp in Sources */,
|
||||||
|
@ -1960,6 +2109,7 @@
|
||||||
27C666DA1C9584050021E494 /* DefaultErrorStrategy.cpp in Sources */,
|
27C666DA1C9584050021E494 /* DefaultErrorStrategy.cpp in Sources */,
|
||||||
27C667FE1C95846E0021E494 /* LL1Analyzer.cpp in Sources */,
|
27C667FE1C95846E0021E494 /* LL1Analyzer.cpp in Sources */,
|
||||||
27C6699B1C9585B80021E494 /* ParseTreeListener.cpp in Sources */,
|
27C6699B1C9585B80021E494 /* ParseTreeListener.cpp in Sources */,
|
||||||
|
27C7D08C1CD10D1900F7E81F /* VocabularyImpl.cpp in Sources */,
|
||||||
27C66A081C958AB30021E494 /* RuleTagToken.cpp in Sources */,
|
27C66A081C958AB30021E494 /* RuleTagToken.cpp in Sources */,
|
||||||
27C667061C9584050021E494 /* ListTokenSource.cpp in Sources */,
|
27C667061C9584050021E494 /* ListTokenSource.cpp in Sources */,
|
||||||
27C6699F1C9585B80021E494 /* ParseTreeProperty.cpp in Sources */,
|
27C6699F1C9585B80021E494 /* ParseTreeProperty.cpp in Sources */,
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace runtime {
|
||||||
/// the reporting of an error. It is null in the case where
|
/// the reporting of an error. It is null in the case where
|
||||||
/// the parser was able to recover in line without exiting the
|
/// the parser was able to recover in line without exiting the
|
||||||
/// surrounding rule. </param>
|
/// surrounding rule. </param>
|
||||||
virtual void syntaxError(IRecognizer *recognizer, Token::Ref offendingSymbol, size_t line, int charPositionInLine,
|
virtual void syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, size_t line, int charPositionInLine,
|
||||||
const std::wstring &msg, std::exception_ptr e) = 0;
|
const std::wstring &msg, std::exception_ptr e) = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -108,7 +108,7 @@ namespace runtime {
|
||||||
/// <param name="configs"> the ATN configuration set where the ambiguity was
|
/// <param name="configs"> the ATN configuration set where the ambiguity was
|
||||||
/// determined </param>
|
/// determined </param>
|
||||||
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
||||||
const antlrcpp::BitSet &ambigAlts, std::shared_ptr<atn::ATNConfigSet> configs) = 0;
|
const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when an SLL conflict occurs and the parser is about
|
/// This method is called when an SLL conflict occurs and the parser is about
|
||||||
|
@ -131,7 +131,7 @@ namespace runtime {
|
||||||
/// <param name="configs"> the ATN configuration set where the SLL conflict was
|
/// <param name="configs"> the ATN configuration set where the SLL conflict was
|
||||||
/// detected </param>
|
/// detected </param>
|
||||||
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
const antlrcpp::BitSet &conflictingAlts, std::shared_ptr<atn::ATNConfigSet> configs) = 0;
|
const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called by the parser when a full-context prediction has a
|
/// This method is called by the parser when a full-context prediction has a
|
||||||
|
@ -161,7 +161,7 @@ namespace runtime {
|
||||||
/// <param name="configs"> the ATN configuration set where the unambiguous prediction
|
/// <param name="configs"> the ATN configuration set where the unambiguous prediction
|
||||||
/// was determined </param>
|
/// was determined </param>
|
||||||
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
int prediction, std::shared_ptr<atn::ATNConfigSet> configs) = 0;
|
int prediction, Ref<atn::ATNConfigSet> configs) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace runtime {
|
||||||
/// <param name="recognizer"> the parser instance </param>
|
/// <param name="recognizer"> the parser instance </param>
|
||||||
/// <exception cref="RecognitionException"> if the error strategy was not able to
|
/// <exception cref="RecognitionException"> if the error strategy was not able to
|
||||||
/// recover from the unexpected input symbol </exception>
|
/// recover from the unexpected input symbol </exception>
|
||||||
virtual Token::Ref recoverInline(Parser *recognizer) = 0;
|
virtual Ref<Token> recoverInline(Parser *recognizer) = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called to recover from exception {@code e}. This method is
|
/// This method is called to recover from exception {@code e}. This method is
|
||||||
|
|
|
@ -40,7 +40,7 @@ using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
void BailErrorStrategy::recover(Parser *recognizer, const RecognitionException &e) {
|
void BailErrorStrategy::recover(Parser *recognizer, const RecognitionException &e) {
|
||||||
std::exception_ptr exception = std::make_exception_ptr(e);
|
std::exception_ptr exception = std::make_exception_ptr(e);
|
||||||
ParserRuleContext::Ref context = recognizer->getContext();
|
Ref<ParserRuleContext> context = recognizer->getContext();
|
||||||
do {
|
do {
|
||||||
context->exception = exception;
|
context->exception = exception;
|
||||||
if (context->getParent().expired())
|
if (context->getParent().expired())
|
||||||
|
@ -60,11 +60,11 @@ void BailErrorStrategy::recover(Parser *recognizer, const RecognitionException &
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref BailErrorStrategy::recoverInline(Parser *recognizer) {
|
Ref<Token> BailErrorStrategy::recoverInline(Parser *recognizer) {
|
||||||
InputMismatchException e(recognizer);
|
InputMismatchException e(recognizer);
|
||||||
std::exception_ptr exception = std::make_exception_ptr(e);
|
std::exception_ptr exception = std::make_exception_ptr(e);
|
||||||
|
|
||||||
ParserRuleContext::Ref context = recognizer->getContext();
|
Ref<ParserRuleContext> context = recognizer->getContext();
|
||||||
do {
|
do {
|
||||||
context->exception = exception;
|
context->exception = exception;
|
||||||
if (context->getParent().expired())
|
if (context->getParent().expired())
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace runtime {
|
||||||
/// Make sure we don't attempt to recover inline; if the parser
|
/// Make sure we don't attempt to recover inline; if the parser
|
||||||
/// successfully recovers, it won't throw an exception.
|
/// successfully recovers, it won't throw an exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual Token::Ref recoverInline(Parser *recognizer) override;
|
virtual Ref<Token> recoverInline(Parser *recognizer) override;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make sure we don't attempt to recover from problems in subrules. </summary>
|
/// Make sure we don't attempt to recover from problems in subrules. </summary>
|
||||||
|
|
|
@ -34,18 +34,18 @@
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
void BaseErrorListener::syntaxError(IRecognizer *recognizer, Token::Ref offendingSymbol, size_t line, int charPositionInLine,
|
void BaseErrorListener::syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, size_t line, int charPositionInLine,
|
||||||
const std::wstring &msg, std::exception_ptr e) {
|
const std::wstring &msg, std::exception_ptr e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
void BaseErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
bool exact, const antlrcpp::BitSet &ambigAlts, std::shared_ptr<atn::ATNConfigSet> configs) {
|
bool exact, const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
void BaseErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
||||||
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, std::shared_ptr<atn::ATNConfigSet> configs) {
|
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
void BaseErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
int prediction, std::shared_ptr<atn::ATNConfigSet> configs) {
|
int prediction, Ref<atn::ATNConfigSet> configs) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,17 +44,17 @@ namespace runtime {
|
||||||
|
|
||||||
class BaseErrorListener : public ANTLRErrorListener {
|
class BaseErrorListener : public ANTLRErrorListener {
|
||||||
|
|
||||||
virtual void syntaxError(IRecognizer *recognizer, Token::Ref offendingSymbol, size_t line, int charPositionInLine,
|
virtual void syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, size_t line, int charPositionInLine,
|
||||||
const std::wstring &msg, std::exception_ptr e) override;
|
const std::wstring &msg, std::exception_ptr e) override;
|
||||||
|
|
||||||
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
||||||
const antlrcpp::BitSet &ambigAlts, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) override;
|
||||||
|
|
||||||
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
const antlrcpp::BitSet &conflictingAlts, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) override;
|
||||||
|
|
||||||
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
int prediction, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
int prediction, Ref<atn::ATNConfigSet> configs) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -103,7 +103,7 @@ size_t BufferedTokenStream::fetch(size_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < n; i++) {
|
for (size_t i = 0; i < n; i++) {
|
||||||
Token::Ref t = _tokenSource->nextToken();
|
Ref<Token> t = _tokenSource->nextToken();
|
||||||
if (is<WritableToken>(t)) {
|
if (is<WritableToken>(t)) {
|
||||||
(std::dynamic_pointer_cast<WritableToken>(t))->setTokenIndex((int)_tokens.size());
|
(std::dynamic_pointer_cast<WritableToken>(t))->setTokenIndex((int)_tokens.size());
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ size_t BufferedTokenStream::fetch(size_t n) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref BufferedTokenStream::get(size_t i) const {
|
Ref<Token> BufferedTokenStream::get(size_t i) const {
|
||||||
if (i >= _tokens.size()) {
|
if (i >= _tokens.size()) {
|
||||||
throw IndexOutOfBoundsException(std::string("token index ") +
|
throw IndexOutOfBoundsException(std::string("token index ") +
|
||||||
std::to_string(i) +
|
std::to_string(i) +
|
||||||
|
@ -127,8 +127,8 @@ Token::Ref BufferedTokenStream::get(size_t i) const {
|
||||||
return _tokens[i];
|
return _tokens[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::get(size_t start, size_t stop) {
|
std::vector<Ref<Token>> BufferedTokenStream::get(size_t start, size_t stop) {
|
||||||
std::vector<Token::Ref> subset;
|
std::vector<Ref<Token>> subset;
|
||||||
|
|
||||||
lazyInit();
|
lazyInit();
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ std::vector<Token::Ref> BufferedTokenStream::get(size_t start, size_t stop) {
|
||||||
stop = _tokens.size() - 1;
|
stop = _tokens.size() - 1;
|
||||||
}
|
}
|
||||||
for (size_t i = start; i <= stop; i++) {
|
for (size_t i = start; i <= stop; i++) {
|
||||||
Token::Ref t = _tokens[i];
|
Ref<Token> t = _tokens[i];
|
||||||
if (t->getType() == EOF) {
|
if (t->getType() == EOF) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -153,14 +153,14 @@ ssize_t BufferedTokenStream::LA(ssize_t i) {
|
||||||
return LT(i)->getType();
|
return LT(i)->getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref BufferedTokenStream::LB(size_t k) {
|
Ref<Token> BufferedTokenStream::LB(size_t k) {
|
||||||
if (k > _p) {
|
if (k > _p) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return _tokens[(size_t)(_p - k)];
|
return _tokens[(size_t)(_p - k)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref BufferedTokenStream::LT(ssize_t k) {
|
Ref<Token> BufferedTokenStream::LT(ssize_t k) {
|
||||||
lazyInit();
|
lazyInit();
|
||||||
if (k == 0) {
|
if (k == 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -201,15 +201,15 @@ void BufferedTokenStream::setTokenSource(TokenSource *tokenSource) {
|
||||||
_needSetup = true;
|
_needSetup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getTokens() {
|
std::vector<Ref<Token>> BufferedTokenStream::getTokens() {
|
||||||
return _tokens;
|
return _tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getTokens(int start, int stop) {
|
std::vector<Ref<Token>> BufferedTokenStream::getTokens(int start, int stop) {
|
||||||
return getTokens(start, stop, std::vector<int>());
|
return getTokens(start, stop, std::vector<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getTokens(int start, int stop, const std::vector<int> &types) {
|
std::vector<Ref<Token>> BufferedTokenStream::getTokens(int start, int stop, const std::vector<int> &types) {
|
||||||
lazyInit();
|
lazyInit();
|
||||||
if (start < 0 || stop >= (int)_tokens.size() || stop < 0 || start >= (int)_tokens.size()) {
|
if (start < 0 || stop >= (int)_tokens.size() || stop < 0 || start >= (int)_tokens.size()) {
|
||||||
throw IndexOutOfBoundsException(std::string("start ") +
|
throw IndexOutOfBoundsException(std::string("start ") +
|
||||||
|
@ -220,7 +220,7 @@ std::vector<Token::Ref> BufferedTokenStream::getTokens(int start, int stop, cons
|
||||||
std::to_string(_tokens.size() - 1));
|
std::to_string(_tokens.size() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> filteredTokens;
|
std::vector<Ref<Token>> filteredTokens;
|
||||||
|
|
||||||
if (start > stop) {
|
if (start > stop) {
|
||||||
return filteredTokens;
|
return filteredTokens;
|
||||||
|
@ -228,7 +228,7 @@ std::vector<Token::Ref> BufferedTokenStream::getTokens(int start, int stop, cons
|
||||||
|
|
||||||
// list = tokens[start:stop]:{T t, t.getType() in types}
|
// list = tokens[start:stop]:{T t, t.getType() in types}
|
||||||
for (size_t i = (size_t)start; i <= (size_t)stop; i++) {
|
for (size_t i = (size_t)start; i <= (size_t)stop; i++) {
|
||||||
Token::Ref tok = _tokens[i];
|
Ref<Token> tok = _tokens[i];
|
||||||
|
|
||||||
if (types.empty() || std::find(types.begin(), types.end(), tok->getType()) != types.end()) {
|
if (types.empty() || std::find(types.begin(), types.end(), tok->getType()) != types.end()) {
|
||||||
filteredTokens.push_back(tok);
|
filteredTokens.push_back(tok);
|
||||||
|
@ -237,7 +237,7 @@ std::vector<Token::Ref> BufferedTokenStream::getTokens(int start, int stop, cons
|
||||||
return filteredTokens;
|
return filteredTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getTokens(int start, int stop, int ttype) {
|
std::vector<Ref<Token>> BufferedTokenStream::getTokens(int start, int stop, int ttype) {
|
||||||
std::vector<int> s;
|
std::vector<int> s;
|
||||||
s.push_back(ttype);
|
s.push_back(ttype);
|
||||||
return getTokens(start, stop, s);
|
return getTokens(start, stop, s);
|
||||||
|
@ -249,7 +249,7 @@ ssize_t BufferedTokenStream::nextTokenOnChannel(size_t i, int channel) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref token = _tokens[i];
|
Ref<Token> token = _tokens[i];
|
||||||
while (token->getChannel() != channel) {
|
while (token->getChannel() != channel) {
|
||||||
if (token->getType() == EOF) {
|
if (token->getType() == EOF) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -272,7 +272,7 @@ ssize_t BufferedTokenStream::previousTokenOnChannel(ssize_t i, int channel) cons
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getHiddenTokensToRight(size_t tokenIndex, int channel) {
|
std::vector<Ref<Token>> BufferedTokenStream::getHiddenTokensToRight(size_t tokenIndex, int channel) {
|
||||||
lazyInit();
|
lazyInit();
|
||||||
if (tokenIndex >= _tokens.size()) {
|
if (tokenIndex >= _tokens.size()) {
|
||||||
throw IndexOutOfBoundsException(std::to_string(tokenIndex) + " not in 0.." + std::to_string(_tokens.size() - 1));
|
throw IndexOutOfBoundsException(std::to_string(tokenIndex) + " not in 0.." + std::to_string(_tokens.size() - 1));
|
||||||
|
@ -291,11 +291,11 @@ std::vector<Token::Ref> BufferedTokenStream::getHiddenTokensToRight(size_t token
|
||||||
return filterForChannel(from, (size_t)to, channel);
|
return filterForChannel(from, (size_t)to, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getHiddenTokensToRight(size_t tokenIndex) {
|
std::vector<Ref<Token>> BufferedTokenStream::getHiddenTokensToRight(size_t tokenIndex) {
|
||||||
return getHiddenTokensToRight(tokenIndex, -1);
|
return getHiddenTokensToRight(tokenIndex, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenIndex, int channel) {
|
std::vector<Ref<Token>> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenIndex, int channel) {
|
||||||
lazyInit();
|
lazyInit();
|
||||||
if (tokenIndex >= _tokens.size()) {
|
if (tokenIndex >= _tokens.size()) {
|
||||||
throw IndexOutOfBoundsException(std::to_string(tokenIndex) + " not in 0.." + std::to_string(_tokens.size() - 1));
|
throw IndexOutOfBoundsException(std::to_string(tokenIndex) + " not in 0.." + std::to_string(_tokens.size() - 1));
|
||||||
|
@ -303,7 +303,7 @@ std::vector<Token::Ref> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenI
|
||||||
|
|
||||||
ssize_t prevOnChannel = previousTokenOnChannel((ssize_t)tokenIndex - 1, Lexer::DEFAULT_TOKEN_CHANNEL);
|
ssize_t prevOnChannel = previousTokenOnChannel((ssize_t)tokenIndex - 1, Lexer::DEFAULT_TOKEN_CHANNEL);
|
||||||
if (prevOnChannel == (ssize_t)tokenIndex - 1) {
|
if (prevOnChannel == (ssize_t)tokenIndex - 1) {
|
||||||
return std::vector<Token::Ref>();
|
return { };
|
||||||
}
|
}
|
||||||
// if none onchannel to left, prevOnChannel=-1 then from=0
|
// if none onchannel to left, prevOnChannel=-1 then from=0
|
||||||
size_t from = (size_t)(prevOnChannel + 1);
|
size_t from = (size_t)(prevOnChannel + 1);
|
||||||
|
@ -312,14 +312,14 @@ std::vector<Token::Ref> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenI
|
||||||
return filterForChannel(from, to, channel);
|
return filterForChannel(from, to, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenIndex) {
|
std::vector<Ref<Token>> BufferedTokenStream::getHiddenTokensToLeft(size_t tokenIndex) {
|
||||||
return getHiddenTokensToLeft(tokenIndex, -1);
|
return getHiddenTokensToLeft(tokenIndex, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> BufferedTokenStream::filterForChannel(size_t from, size_t to, int channel) {
|
std::vector<Ref<Token>> BufferedTokenStream::filterForChannel(size_t from, size_t to, int channel) {
|
||||||
std::vector<Token::Ref> hidden;
|
std::vector<Ref<Token>> hidden;
|
||||||
for (size_t i = from; i <= to; i++) {
|
for (size_t i = from; i <= to; i++) {
|
||||||
Token::Ref t = _tokens[i];
|
Ref<Token> t = _tokens[i];
|
||||||
if (channel == -1) {
|
if (channel == -1) {
|
||||||
if (t->getChannel() != Lexer::DEFAULT_TOKEN_CHANNEL) {
|
if (t->getChannel() != Lexer::DEFAULT_TOKEN_CHANNEL) {
|
||||||
hidden.push_back(t);
|
hidden.push_back(t);
|
||||||
|
@ -361,7 +361,7 @@ std::wstring BufferedTokenStream::getText(const misc::Interval &interval) {
|
||||||
|
|
||||||
std::wstringstream ss;
|
std::wstringstream ss;
|
||||||
for (size_t i = (size_t)start; i <= (size_t)stop; i++) {
|
for (size_t i = (size_t)start; i <= (size_t)stop; i++) {
|
||||||
Token::Ref t = _tokens[i];
|
Ref<Token> t = _tokens[i];
|
||||||
if (t->getType() == EOF) {
|
if (t->getType() == EOF) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ std::wstring BufferedTokenStream::getText(RuleContext *ctx) {
|
||||||
return getText(ctx->getSourceInterval());
|
return getText(ctx->getSourceInterval());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring BufferedTokenStream::getText(Token::Ref start, Token::Ref stop) {
|
std::wstring BufferedTokenStream::getText(Ref<Token> start, Ref<Token> stop) {
|
||||||
if (start != nullptr && stop != nullptr) {
|
if (start != nullptr && stop != nullptr) {
|
||||||
return getText(misc::Interval(start->getTokenIndex(), stop->getTokenIndex()));
|
return getText(misc::Interval(start->getTokenIndex(), stop->getTokenIndex()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,57 +63,57 @@ namespace runtime {
|
||||||
virtual size_t size() override;
|
virtual size_t size() override;
|
||||||
virtual void consume() override;
|
virtual void consume() override;
|
||||||
|
|
||||||
virtual Token::Ref get(size_t i) const override;
|
virtual Ref<Token> get(size_t i) const override;
|
||||||
|
|
||||||
/// Get all tokens from start..stop inclusively.
|
/// Get all tokens from start..stop inclusively.
|
||||||
virtual std::vector<Token::Ref> get(size_t start, size_t stop);
|
virtual std::vector<Ref<Token>> get(size_t start, size_t stop);
|
||||||
|
|
||||||
virtual ssize_t LA(ssize_t i) override;
|
virtual ssize_t LA(ssize_t i) override;
|
||||||
virtual Token::Ref LT(ssize_t k) override;
|
virtual Ref<Token> LT(ssize_t k) override;
|
||||||
|
|
||||||
/// Reset this token stream by setting its token source.
|
/// Reset this token stream by setting its token source.
|
||||||
virtual void setTokenSource(TokenSource *tokenSource);
|
virtual void setTokenSource(TokenSource *tokenSource);
|
||||||
virtual std::vector<Token::Ref> getTokens();
|
virtual std::vector<Ref<Token>> getTokens();
|
||||||
virtual std::vector<Token::Ref> getTokens(int start, int stop);
|
virtual std::vector<Ref<Token>> getTokens(int start, int stop);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Given a start and stop index, return a List of all tokens in
|
/// Given a start and stop index, return a List of all tokens in
|
||||||
/// the token type BitSet. Return null if no tokens were found. This
|
/// the token type BitSet. Return null if no tokens were found. This
|
||||||
/// method looks at both on and off channel tokens.
|
/// method looks at both on and off channel tokens.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual std::vector<Token::Ref> getTokens(int start, int stop, const std::vector<int> &types);
|
virtual std::vector<Ref<Token>> getTokens(int start, int stop, const std::vector<int> &types);
|
||||||
virtual std::vector<Token::Ref> getTokens(int start, int stop, int ttype);
|
virtual std::vector<Ref<Token>> getTokens(int start, int stop, int ttype);
|
||||||
|
|
||||||
/// Collect all tokens on specified channel to the right of
|
/// Collect all tokens on specified channel to the right of
|
||||||
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or
|
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or
|
||||||
/// EOF. If channel is -1, find any non default channel token.
|
/// EOF. If channel is -1, find any non default channel token.
|
||||||
virtual std::vector<Token::Ref> getHiddenTokensToRight(size_t tokenIndex, int channel);
|
virtual std::vector<Ref<Token>> getHiddenTokensToRight(size_t tokenIndex, int channel);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Collect all hidden tokens (any off-default channel) to the right of
|
/// Collect all hidden tokens (any off-default channel) to the right of
|
||||||
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL
|
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL
|
||||||
/// of EOF.
|
/// of EOF.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual std::vector<Token::Ref> getHiddenTokensToRight(size_t tokenIndex);
|
virtual std::vector<Ref<Token>> getHiddenTokensToRight(size_t tokenIndex);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Collect all tokens on specified channel to the left of
|
/// Collect all tokens on specified channel to the left of
|
||||||
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
|
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
|
||||||
/// If channel is -1, find any non default channel token.
|
/// If channel is -1, find any non default channel token.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual std::vector<Token::Ref> getHiddenTokensToLeft(size_t tokenIndex, int channel);
|
virtual std::vector<Ref<Token>> getHiddenTokensToLeft(size_t tokenIndex, int channel);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Collect all hidden tokens (any off-default channel) to the left of
|
/// Collect all hidden tokens (any off-default channel) to the left of
|
||||||
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
|
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual std::vector<Token::Ref> getHiddenTokensToLeft(size_t tokenIndex);
|
virtual std::vector<Ref<Token>> getHiddenTokensToLeft(size_t tokenIndex);
|
||||||
|
|
||||||
virtual std::string getSourceName() const override;
|
virtual std::string getSourceName() const override;
|
||||||
virtual std::wstring getText() override;
|
virtual std::wstring getText() override;
|
||||||
virtual std::wstring getText(const misc::Interval &interval) override;
|
virtual std::wstring getText(const misc::Interval &interval) override;
|
||||||
virtual std::wstring getText(RuleContext *ctx) override;
|
virtual std::wstring getText(RuleContext *ctx) override;
|
||||||
virtual std::wstring getText(Token::Ref start, Token::Ref stop) override;
|
virtual std::wstring getText(Ref<Token> start, Ref<Token> stop) override;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all tokens from lexer until EOF </summary>
|
/// Get all tokens from lexer until EOF </summary>
|
||||||
|
@ -126,7 +126,7 @@ namespace runtime {
|
||||||
/// chunks of it later. This list captures everything so we can access
|
/// chunks of it later. This list captures everything so we can access
|
||||||
/// complete input text.
|
/// complete input text.
|
||||||
// ml: we own the tokens produced by the token factory.
|
// ml: we own the tokens produced by the token factory.
|
||||||
std::vector<Token::Ref> _tokens;
|
std::vector<Ref<Token>> _tokens;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The index into <seealso cref="#tokens"/> of the current token (next token to
|
/// The index into <seealso cref="#tokens"/> of the current token (next token to
|
||||||
|
@ -160,7 +160,7 @@ namespace runtime {
|
||||||
/// <returns> The actual number of elements added to the buffer. </returns>
|
/// <returns> The actual number of elements added to the buffer. </returns>
|
||||||
virtual size_t fetch(size_t n);
|
virtual size_t fetch(size_t n);
|
||||||
|
|
||||||
virtual Token::Ref LB(size_t k);
|
virtual Ref<Token> LB(size_t k);
|
||||||
|
|
||||||
/// Allowed derived classes to modify the behavior of operations which change
|
/// Allowed derived classes to modify the behavior of operations which change
|
||||||
/// the current stream position by adjusting the target token index of a seek
|
/// the current stream position by adjusting the target token index of a seek
|
||||||
|
@ -187,7 +187,7 @@ namespace runtime {
|
||||||
/// on channel between i and 0.
|
/// on channel between i and 0.
|
||||||
virtual ssize_t previousTokenOnChannel(ssize_t i, int channel) const;
|
virtual ssize_t previousTokenOnChannel(ssize_t i, int channel) const;
|
||||||
|
|
||||||
virtual std::vector<Token::Ref> filterForChannel(size_t from, size_t to, int channel);
|
virtual std::vector<Ref<Token>> filterForChannel(size_t from, size_t to, int channel);
|
||||||
private:
|
private:
|
||||||
bool _needSetup;
|
bool _needSetup;
|
||||||
void InitializeInstanceFields();
|
void InitializeInstanceFields();
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
const std::shared_ptr<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT = std::make_shared<CommonTokenFactory>();
|
const Ref<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT = std::make_shared<CommonTokenFactory>();
|
||||||
|
|
||||||
CommonTokenFactory::CommonTokenFactory(bool copyText) : copyText(copyText) {
|
CommonTokenFactory::CommonTokenFactory(bool copyText) : copyText(copyText) {
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ CommonTokenFactory::CommonTokenFactory(bool copyText) : copyText(copyText) {
|
||||||
CommonTokenFactory::CommonTokenFactory() : CommonTokenFactory(false) {
|
CommonTokenFactory::CommonTokenFactory() : CommonTokenFactory(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CommonToken> CommonTokenFactory::create(std::pair<TokenSource*, CharStream*> source, int type,
|
Ref<CommonToken> CommonTokenFactory::create(std::pair<TokenSource*, CharStream*> source, int type,
|
||||||
const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) {
|
const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) {
|
||||||
|
|
||||||
std::shared_ptr<CommonToken> t = std::make_shared<CommonToken>(source, type, channel, start, stop);
|
Ref<CommonToken> t = std::make_shared<CommonToken>(source, type, channel, start, stop);
|
||||||
t->setLine(line);
|
t->setLine(line);
|
||||||
t->setCharPositionInLine(charPositionInLine);
|
t->setCharPositionInLine(charPositionInLine);
|
||||||
if (text != L"") {
|
if (text != L"") {
|
||||||
|
@ -60,6 +60,6 @@ std::shared_ptr<CommonToken> CommonTokenFactory::create(std::pair<TokenSource*,
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CommonToken> CommonTokenFactory::create(int type, const std::wstring &text) {
|
Ref<CommonToken> CommonTokenFactory::create(int type, const std::wstring &text) {
|
||||||
return std::make_shared<CommonToken>(type, text);
|
return std::make_shared<CommonToken>(type, text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace runtime {
|
||||||
|
|
||||||
class CommonTokenFactory : public TokenFactory<CommonToken> {
|
class CommonTokenFactory : public TokenFactory<CommonToken> {
|
||||||
public:
|
public:
|
||||||
static const std::shared_ptr<TokenFactory<CommonToken>> DEFAULT;
|
static const Ref<TokenFactory<CommonToken>> DEFAULT;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Copy text for token out of input char stream. Useful when input
|
/// Copy text for token out of input char stream. Useful when input
|
||||||
|
@ -56,10 +56,10 @@ namespace runtime {
|
||||||
|
|
||||||
CommonTokenFactory();
|
CommonTokenFactory();
|
||||||
|
|
||||||
virtual std::shared_ptr<CommonToken> create(std::pair<TokenSource*, CharStream*> source, int type,
|
virtual Ref<CommonToken> create(std::pair<TokenSource*, CharStream*> source, int type,
|
||||||
const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) override;
|
const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<CommonToken> create(int type, const std::wstring &text) override;
|
virtual Ref<CommonToken> create(int type, const std::wstring &text) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -47,9 +47,9 @@ ssize_t CommonTokenStream::adjustSeekIndex(size_t i) {
|
||||||
return nextTokenOnChannel(i, channel);
|
return nextTokenOnChannel(i, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref CommonTokenStream::LB(size_t k) {
|
Ref<Token> CommonTokenStream::LB(size_t k) {
|
||||||
if (k == 0 || k > _p) {
|
if (k == 0 || k > _p) {
|
||||||
return Token::Ref();
|
return Ref<Token>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t i = (ssize_t)_p;
|
ssize_t i = (ssize_t)_p;
|
||||||
|
@ -67,7 +67,7 @@ Token::Ref CommonTokenStream::LB(size_t k) {
|
||||||
return _tokens[i];
|
return _tokens[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref CommonTokenStream::LT(ssize_t k) {
|
Ref<Token> CommonTokenStream::LT(ssize_t k) {
|
||||||
lazyInit();
|
lazyInit();
|
||||||
if (k == 0) {
|
if (k == 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -93,7 +93,7 @@ int CommonTokenStream::getNumberOfOnChannelTokens() {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
fill();
|
fill();
|
||||||
for (size_t i = 0; i < _tokens.size(); i++) {
|
for (size_t i = 0; i < _tokens.size(); i++) {
|
||||||
Token::Ref t = _tokens[i];
|
Ref<Token> t = _tokens[i];
|
||||||
if (t->getChannel() == channel) {
|
if (t->getChannel() == channel) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,10 @@ namespace runtime {
|
||||||
protected:
|
protected:
|
||||||
virtual ssize_t adjustSeekIndex(size_t i) override;
|
virtual ssize_t adjustSeekIndex(size_t i) override;
|
||||||
|
|
||||||
virtual Token::Ref LB(size_t k) override;
|
virtual Ref<Token> LB(size_t k) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual Token::Ref LT(ssize_t k) override;
|
virtual Ref<Token> LT(ssize_t k) override;
|
||||||
|
|
||||||
/// Count EOF just once.
|
/// Count EOF just once.
|
||||||
virtual int getNumberOfOnChannelTokens();
|
virtual int getNumberOfOnChannelTokens();
|
||||||
|
|
|
@ -35,7 +35,7 @@ using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
ConsoleErrorListener ConsoleErrorListener::INSTANCE;
|
ConsoleErrorListener ConsoleErrorListener::INSTANCE;
|
||||||
|
|
||||||
void ConsoleErrorListener::syntaxError(IRecognizer *recognizer, Token::Ref offendingSymbol,
|
void ConsoleErrorListener::syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol,
|
||||||
size_t line, int charPositionInLine, const std::wstring &msg, std::exception_ptr e) {
|
size_t line, int charPositionInLine, const std::wstring &msg, std::exception_ptr e) {
|
||||||
std::wcerr << L"line " << line << L":" << charPositionInLine << L" " << msg << std::endl;
|
std::wcerr << L"line " << line << L":" << charPositionInLine << L" " << msg << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,8 @@ namespace runtime {
|
||||||
public:
|
public:
|
||||||
static ConsoleErrorListener INSTANCE;
|
static ConsoleErrorListener INSTANCE;
|
||||||
|
|
||||||
virtual void syntaxError(IRecognizer *recognizer, Token::Ref offendingSymbol, size_t line, int charPositionInLine, const std::wstring &msg, std::exception_ptr e) override;
|
virtual void syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, size_t line, int charPositionInLine,
|
||||||
|
const std::wstring &msg, std::exception_ptr e) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -191,7 +191,7 @@ void DefaultErrorStrategy::reportUnwantedToken(Parser *recognizer) {
|
||||||
|
|
||||||
beginErrorCondition(recognizer);
|
beginErrorCondition(recognizer);
|
||||||
|
|
||||||
Token::Ref t = recognizer->getCurrentToken();
|
Ref<Token> t = recognizer->getCurrentToken();
|
||||||
std::wstring tokenName = getTokenErrorDisplay(t);
|
std::wstring tokenName = getTokenErrorDisplay(t);
|
||||||
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
||||||
|
|
||||||
|
@ -206,16 +206,16 @@ void DefaultErrorStrategy::reportMissingToken(Parser *recognizer) {
|
||||||
|
|
||||||
beginErrorCondition(recognizer);
|
beginErrorCondition(recognizer);
|
||||||
|
|
||||||
Token::Ref t = recognizer->getCurrentToken();
|
Ref<Token> t = recognizer->getCurrentToken();
|
||||||
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
||||||
std::wstring msg = std::wstring(L"missing ") + expecting.toString(recognizer->getTokenNames()) + std::wstring(L" at ") + getTokenErrorDisplay(t);
|
std::wstring msg = std::wstring(L"missing ") + expecting.toString(recognizer->getTokenNames()) + std::wstring(L" at ") + getTokenErrorDisplay(t);
|
||||||
|
|
||||||
recognizer->notifyErrorListeners(t, msg, nullptr);
|
recognizer->notifyErrorListeners(t, msg, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref DefaultErrorStrategy::recoverInline(Parser *recognizer) {
|
Ref<Token> DefaultErrorStrategy::recoverInline(Parser *recognizer) {
|
||||||
// SINGLE TOKEN DELETION
|
// SINGLE TOKEN DELETION
|
||||||
Token::Ref matchedSymbol = singleTokenDeletion(recognizer);
|
Ref<Token> matchedSymbol = singleTokenDeletion(recognizer);
|
||||||
if (matchedSymbol) {
|
if (matchedSymbol) {
|
||||||
// we have deleted the extra token.
|
// we have deleted the extra token.
|
||||||
// now, move past ttype token as if all were ok
|
// now, move past ttype token as if all were ok
|
||||||
|
@ -249,22 +249,22 @@ bool DefaultErrorStrategy::singleTokenInsertion(Parser *recognizer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref DefaultErrorStrategy::singleTokenDeletion(Parser *recognizer) {
|
Ref<Token> DefaultErrorStrategy::singleTokenDeletion(Parser *recognizer) {
|
||||||
ssize_t nextTokenType = recognizer->getInputStream()->LA(2);
|
ssize_t nextTokenType = recognizer->getInputStream()->LA(2);
|
||||||
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
||||||
if (expecting.contains((int)nextTokenType)) {
|
if (expecting.contains((int)nextTokenType)) {
|
||||||
reportUnwantedToken(recognizer);
|
reportUnwantedToken(recognizer);
|
||||||
recognizer->consume(); // simply delete extra token
|
recognizer->consume(); // simply delete extra token
|
||||||
// we want to return the token we're actually matching
|
// we want to return the token we're actually matching
|
||||||
Token::Ref matchedSymbol = recognizer->getCurrentToken();
|
Ref<Token> matchedSymbol = recognizer->getCurrentToken();
|
||||||
reportMatch(recognizer); // we know current token is correct
|
reportMatch(recognizer); // we know current token is correct
|
||||||
return matchedSymbol;
|
return matchedSymbol;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref DefaultErrorStrategy::getMissingSymbol(Parser *recognizer) {
|
Ref<Token> DefaultErrorStrategy::getMissingSymbol(Parser *recognizer) {
|
||||||
Token::Ref currentSymbol = recognizer->getCurrentToken();
|
Ref<Token> currentSymbol = recognizer->getCurrentToken();
|
||||||
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
misc::IntervalSet expecting = getExpectedTokens(recognizer);
|
||||||
ssize_t expectedTokenType = expecting.getMinElement(); // get any element
|
ssize_t expectedTokenType = expecting.getMinElement(); // get any element
|
||||||
std::wstring tokenText;
|
std::wstring tokenText;
|
||||||
|
@ -273,8 +273,8 @@ Token::Ref DefaultErrorStrategy::getMissingSymbol(Parser *recognizer) {
|
||||||
} else {
|
} else {
|
||||||
tokenText = std::wstring(L"<missing ") + recognizer->getTokenNames()[(size_t)expectedTokenType] + std::wstring(L">");
|
tokenText = std::wstring(L"<missing ") + recognizer->getTokenNames()[(size_t)expectedTokenType] + std::wstring(L">");
|
||||||
}
|
}
|
||||||
Token::Ref current = currentSymbol;
|
Ref<Token> current = currentSymbol;
|
||||||
Token::Ref lookback = recognizer->getTokenStream()->LT(-1);
|
Ref<Token> lookback = recognizer->getTokenStream()->LT(-1);
|
||||||
if (current->getType() == EOF && lookback != nullptr) {
|
if (current->getType() == EOF && lookback != nullptr) {
|
||||||
current = lookback;
|
current = lookback;
|
||||||
}
|
}
|
||||||
|
@ -287,9 +287,9 @@ misc::IntervalSet DefaultErrorStrategy::getExpectedTokens(Parser *recognizer) {
|
||||||
return recognizer->getExpectedTokens();
|
return recognizer->getExpectedTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring DefaultErrorStrategy::getTokenErrorDisplay(Token::Ref t) {
|
std::wstring DefaultErrorStrategy::getTokenErrorDisplay(Ref<Token> t) {
|
||||||
if (t == nullptr) {
|
if (t == nullptr) {
|
||||||
return L"<no token>";
|
return L"<no Token>";
|
||||||
}
|
}
|
||||||
std::wstring s = getSymbolText(t);
|
std::wstring s = getSymbolText(t);
|
||||||
if (s == L"") {
|
if (s == L"") {
|
||||||
|
@ -302,11 +302,11 @@ std::wstring DefaultErrorStrategy::getTokenErrorDisplay(Token::Ref t) {
|
||||||
return escapeWSAndQuote(s);
|
return escapeWSAndQuote(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring DefaultErrorStrategy::getSymbolText(Token::Ref symbol) {
|
std::wstring DefaultErrorStrategy::getSymbolText(Ref<Token> symbol) {
|
||||||
return symbol->getText();
|
return symbol->getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefaultErrorStrategy::getSymbolType(Token::Ref symbol) {
|
int DefaultErrorStrategy::getSymbolType(Ref<Token> symbol) {
|
||||||
return symbol->getType();
|
return symbol->getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ std::wstring DefaultErrorStrategy::escapeWSAndQuote(std::wstring &s) {
|
||||||
|
|
||||||
misc::IntervalSet DefaultErrorStrategy::getErrorRecoverySet(Parser *recognizer) {
|
misc::IntervalSet DefaultErrorStrategy::getErrorRecoverySet(Parser *recognizer) {
|
||||||
const atn::ATN &atn = recognizer->getInterpreter<atn::ATNSimulator>()->atn;
|
const atn::ATN &atn = recognizer->getInterpreter<atn::ATNSimulator>()->atn;
|
||||||
RuleContext::Ref ctx = recognizer->getContext();
|
Ref<RuleContext> ctx = recognizer->getContext();
|
||||||
misc::IntervalSet recoverSet;
|
misc::IntervalSet recoverSet;
|
||||||
while (ctx->invokingState >= 0) {
|
while (ctx->invokingState >= 0) {
|
||||||
// compute what follows who invoked us
|
// compute what follows who invoked us
|
||||||
|
|
|
@ -305,7 +305,7 @@ namespace runtime {
|
||||||
/// in rule {@code atom}. It can assume that you forgot the {@code ')'}.
|
/// in rule {@code atom}. It can assume that you forgot the {@code ')'}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public:
|
public:
|
||||||
virtual Token::Ref recoverInline(Parser *recognizer) override;
|
virtual Ref<Token> recoverInline(Parser *recognizer) override;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method implements the single-token insertion inline error recovery
|
/// This method implements the single-token insertion inline error recovery
|
||||||
|
@ -344,7 +344,7 @@ namespace runtime {
|
||||||
/// <returns> the successfully matched <seealso cref="Token"/> instance if single-token
|
/// <returns> the successfully matched <seealso cref="Token"/> instance if single-token
|
||||||
/// deletion successfully recovers from the mismatched input, otherwise
|
/// deletion successfully recovers from the mismatched input, otherwise
|
||||||
/// {@code null} </returns>
|
/// {@code null} </returns>
|
||||||
virtual Token::Ref singleTokenDeletion(Parser *recognizer);
|
virtual Ref<Token> singleTokenDeletion(Parser *recognizer);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Conjure up a missing token during error recovery.
|
/// Conjure up a missing token during error recovery.
|
||||||
|
@ -366,7 +366,7 @@ namespace runtime {
|
||||||
/// If you change what tokens must be created by the lexer,
|
/// If you change what tokens must be created by the lexer,
|
||||||
/// override this method to create the appropriate tokens.
|
/// override this method to create the appropriate tokens.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual Token::Ref getMissingSymbol(Parser *recognizer);
|
virtual Ref<Token> getMissingSymbol(Parser *recognizer);
|
||||||
|
|
||||||
virtual misc::IntervalSet getExpectedTokens(Parser *recognizer);
|
virtual misc::IntervalSet getExpectedTokens(Parser *recognizer);
|
||||||
|
|
||||||
|
@ -379,11 +379,11 @@ namespace runtime {
|
||||||
/// your token objects because you don't have to go modify your lexer
|
/// your token objects because you don't have to go modify your lexer
|
||||||
/// so that it creates a new class.
|
/// so that it creates a new class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual std::wstring getTokenErrorDisplay(Token::Ref t);
|
virtual std::wstring getTokenErrorDisplay(Ref<Token> t);
|
||||||
|
|
||||||
virtual std::wstring getSymbolText(Token::Ref symbol);
|
virtual std::wstring getSymbolText(Ref<Token> symbol);
|
||||||
|
|
||||||
virtual int getSymbolType(Token::Ref symbol);
|
virtual int getSymbolType(Ref<Token> symbol);
|
||||||
|
|
||||||
virtual std::wstring escapeWSAndQuote(std::wstring &s);
|
virtual std::wstring escapeWSAndQuote(std::wstring &s);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ DiagnosticErrorListener::DiagnosticErrorListener(bool exactOnly) : exactOnly(exa
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
bool exact, const antlrcpp::BitSet &ambigAlts, std::shared_ptr<atn::ATNConfigSet> configs) {
|
bool exact, const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) {
|
||||||
if (exactOnly && !exact) {
|
if (exactOnly && !exact) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
||||||
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, std::shared_ptr<atn::ATNConfigSet> configs) {
|
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) {
|
||||||
std::wstring decision = getDecisionDescription(recognizer, dfa);
|
std::wstring decision = getDecisionDescription(recognizer, dfa);
|
||||||
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
|
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
|
||||||
std::wstring message = L"reportAttemptingFullContext d = " + decision + L", input = '" + text + L"'";
|
std::wstring message = L"reportAttemptingFullContext d = " + decision + L", input = '" + text + L"'";
|
||||||
|
@ -70,7 +70,7 @@ void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, co
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
||||||
size_t stopIndex, int prediction, std::shared_ptr<atn::ATNConfigSet> configs) {
|
size_t stopIndex, int prediction, Ref<atn::ATNConfigSet> configs) {
|
||||||
std::wstring decision = getDecisionDescription(recognizer, dfa);
|
std::wstring decision = getDecisionDescription(recognizer, dfa);
|
||||||
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
|
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
|
||||||
std::wstring message = L"reportContextSensitivity d = " + decision + L", input = '" + text + L"'";
|
std::wstring message = L"reportContextSensitivity d = " + decision + L", input = '" + text + L"'";
|
||||||
|
@ -95,7 +95,7 @@ std::wstring DiagnosticErrorListener::getDecisionDescription(Parser *recognizer,
|
||||||
}
|
}
|
||||||
|
|
||||||
antlrcpp::BitSet DiagnosticErrorListener::getConflictingAlts(const antlrcpp::BitSet &reportedAlts,
|
antlrcpp::BitSet DiagnosticErrorListener::getConflictingAlts(const antlrcpp::BitSet &reportedAlts,
|
||||||
std::shared_ptr<atn::ATNConfigSet> configs) {
|
Ref<atn::ATNConfigSet> configs) {
|
||||||
if (reportedAlts.count() > 0) { // Not exactly like the original Java code, but this listener is only used
|
if (reportedAlts.count() > 0) { // Not exactly like the original Java code, but this listener is only used
|
||||||
// in the TestRig (where it never provides a good alt set), so it's probably ok so.
|
// in the TestRig (where it never provides a good alt set), so it's probably ok so.
|
||||||
return reportedAlts;
|
return reportedAlts;
|
||||||
|
@ -103,7 +103,7 @@ antlrcpp::BitSet DiagnosticErrorListener::getConflictingAlts(const antlrcpp::Bit
|
||||||
|
|
||||||
antlrcpp::BitSet result;
|
antlrcpp::BitSet result;
|
||||||
for (size_t i = 0; i < configs->size(); i++) {
|
for (size_t i = 0; i < configs->size(); i++) {
|
||||||
atn::ATNConfig::Ref config = configs->get(i);
|
Ref<atn::ATNConfig> config = configs->get(i);
|
||||||
result.set((size_t)config->alt);
|
result.set((size_t)config->alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,13 +82,13 @@ namespace runtime {
|
||||||
DiagnosticErrorListener(bool exactOnly);
|
DiagnosticErrorListener(bool exactOnly);
|
||||||
|
|
||||||
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
||||||
const antlrcpp::BitSet &ambigAlts, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) override;
|
||||||
|
|
||||||
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
const antlrcpp::BitSet &conflictingAlts, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) override;
|
||||||
|
|
||||||
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
int prediction, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
int prediction, Ref<atn::ATNConfigSet> configs) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::wstring getDecisionDescription(Parser *recognizer, const dfa::DFA &dfa);
|
virtual std::wstring getDecisionDescription(Parser *recognizer, const dfa::DFA &dfa);
|
||||||
|
@ -103,7 +103,7 @@ namespace runtime {
|
||||||
/// <param name="configs"> The conflicting or ambiguous configuration set. </param>
|
/// <param name="configs"> The conflicting or ambiguous configuration set. </param>
|
||||||
/// <returns> Returns {@code reportedAlts} if it is not {@code null}, otherwise
|
/// <returns> Returns {@code reportedAlts} if it is not {@code null}, otherwise
|
||||||
/// returns the set of alternatives represented in {@code configs}. </returns>
|
/// returns the set of alternatives represented in {@code configs}. </returns>
|
||||||
virtual antlrcpp::BitSet getConflictingAlts(const antlrcpp::BitSet &reportedAlts, std::shared_ptr<atn::ATNConfigSet> configs);
|
virtual antlrcpp::BitSet getConflictingAlts(const antlrcpp::BitSet &reportedAlts, Ref<atn::ATNConfigSet> configs);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -66,7 +66,7 @@ void Lexer::reset() {
|
||||||
getInterpreter<atn::LexerATNSimulator>()->reset();
|
getInterpreter<atn::LexerATNSimulator>()->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Lexer::nextToken() {
|
Ref<Token> Lexer::nextToken() {
|
||||||
// Mark start location in char stream so unbuffered streams are
|
// Mark start location in char stream so unbuffered streams are
|
||||||
// guaranteed at least have text of current token
|
// guaranteed at least have text of current token
|
||||||
ssize_t tokenStartMarker = _input->mark();
|
ssize_t tokenStartMarker = _input->mark();
|
||||||
|
@ -150,7 +150,7 @@ int Lexer::popMode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<TokenFactory<CommonToken>> Lexer::getTokenFactory() {
|
Ref<TokenFactory<CommonToken>> Lexer::getTokenFactory() {
|
||||||
return _factory;
|
return _factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,27 +167,22 @@ CharStream* Lexer::getInputStream() {
|
||||||
return _input;
|
return _input;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lexer::emit(Token::Ref token) {
|
void Lexer::emit(Ref<Token> token) {
|
||||||
_token = token;
|
_token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Lexer::emit() {
|
Ref<Token> Lexer::emit() {
|
||||||
Token::Ref t = std::dynamic_pointer_cast<Token>(_factory->create({ this, _input }, _type, _text, _channel,
|
Ref<Token> t = std::dynamic_pointer_cast<Token>(_factory->create({ this, _input }, _type, _text, _channel,
|
||||||
_tokenStartCharIndex, getCharIndex() - 1, _tokenStartLine, _tokenStartCharPositionInLine));
|
_tokenStartCharIndex, getCharIndex() - 1, _tokenStartLine, _tokenStartCharPositionInLine));
|
||||||
emit(t);
|
emit(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Lexer::emitEOF() {
|
Ref<Token> Lexer::emitEOF() {
|
||||||
int cpos = getCharPositionInLine();
|
int cpos = getCharPositionInLine();
|
||||||
// The character position for EOF is one beyond the position of
|
size_t line = getLine();
|
||||||
// the previous token's last character
|
Ref<Token> eof = std::dynamic_pointer_cast<Token>(_factory->create({ this, _input }, EOF, L"", Token::DEFAULT_CHANNEL,
|
||||||
if (_token != nullptr) {
|
(int)_input->index(), (int)_input->index() - 1, (int)line, cpos));
|
||||||
int n = _token->getStopIndex() - _token->getStartIndex() + 1;
|
|
||||||
cpos = _token->getCharPositionInLine() + n;
|
|
||||||
}
|
|
||||||
Token::Ref eof = std::dynamic_pointer_cast<Token>(_factory->create({ this, _input }, EOF, L"", Token::DEFAULT_CHANNEL,
|
|
||||||
(int)_input->index(), (int)_input->index() - 1, (int)getLine(), cpos));
|
|
||||||
emit(eof);
|
emit(eof);
|
||||||
return eof;
|
return eof;
|
||||||
}
|
}
|
||||||
|
@ -223,11 +218,11 @@ void Lexer::setText(const std::wstring &text) {
|
||||||
this->_text = text;
|
this->_text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Lexer::getToken() {
|
Ref<Token> Lexer::getToken() {
|
||||||
return _token;
|
return _token;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lexer::setToken(Token::Ref token) {
|
void Lexer::setToken(Ref<Token> token) {
|
||||||
_token = token;
|
_token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,9 +242,9 @@ int Lexer::getChannel() {
|
||||||
return _channel;
|
return _channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Token::Ref> Lexer::getAllTokens() {
|
std::vector<Ref<Token>> Lexer::getAllTokens() {
|
||||||
std::vector<Token::Ref> tokens;
|
std::vector<Ref<Token>> tokens;
|
||||||
Token::Ref t = nextToken();
|
Ref<Token> t = nextToken();
|
||||||
while (t->getType() != EOF) {
|
while (t->getType() != EOF) {
|
||||||
tokens.push_back(t);
|
tokens.push_back(t);
|
||||||
t = nextToken();
|
t = nextToken();
|
||||||
|
|
|
@ -47,8 +47,6 @@ namespace runtime {
|
||||||
/// of speed.
|
/// of speed.
|
||||||
class Lexer : public Recognizer, public TokenSource {
|
class Lexer : public Recognizer, public TokenSource {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<Lexer> Ref;
|
|
||||||
|
|
||||||
static const int DEFAULT_MODE = 0;
|
static const int DEFAULT_MODE = 0;
|
||||||
static const int MORE = -2;
|
static const int MORE = -2;
|
||||||
static const int SKIP = -3;
|
static const int SKIP = -3;
|
||||||
|
@ -62,7 +60,7 @@ namespace runtime {
|
||||||
protected:
|
protected:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How to create token objects </summary>
|
/// How to create token objects </summary>
|
||||||
std::shared_ptr<TokenFactory<CommonToken>> _factory;
|
Ref<TokenFactory<CommonToken>> _factory;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The goal of all lexer rules/methods is to create a token object.
|
/// The goal of all lexer rules/methods is to create a token object.
|
||||||
|
@ -72,7 +70,7 @@ namespace runtime {
|
||||||
/// emissions, then set this to the last token to be matched or
|
/// emissions, then set this to the last token to be matched or
|
||||||
/// something nonnull so that the auto token emit mechanism will not
|
/// something nonnull so that the auto token emit mechanism will not
|
||||||
/// emit another token.
|
/// emit another token.
|
||||||
Token::Ref _token;
|
Ref<Token> _token;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// What character index in the stream did the current token start at?
|
/// What character index in the stream did the current token start at?
|
||||||
|
@ -116,7 +114,7 @@ namespace runtime {
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
/// Return a token from this source; i.e., match a token on the char stream.
|
/// Return a token from this source; i.e., match a token on the char stream.
|
||||||
virtual Token::Ref nextToken() override;
|
virtual Ref<Token> nextToken() override;
|
||||||
|
|
||||||
/// Instruct the lexer to skip creating a token for current lexer rule
|
/// Instruct the lexer to skip creating a token for current lexer rule
|
||||||
/// and look for another token. nextToken() knows to keep looking when
|
/// and look for another token. nextToken() knows to keep looking when
|
||||||
|
@ -124,13 +122,9 @@ namespace runtime {
|
||||||
/// if token == null at end of any token rule, it creates one for you
|
/// if token == null at end of any token rule, it creates one for you
|
||||||
/// and emits it.
|
/// and emits it.
|
||||||
virtual void skip();
|
virtual void skip();
|
||||||
|
|
||||||
virtual void more();
|
virtual void more();
|
||||||
|
|
||||||
virtual void mode(int m);
|
virtual void mode(int m);
|
||||||
|
|
||||||
virtual void pushMode(int m);
|
virtual void pushMode(int m);
|
||||||
|
|
||||||
virtual int popMode();
|
virtual int popMode();
|
||||||
|
|
||||||
template<typename T1>
|
template<typename T1>
|
||||||
|
@ -138,7 +132,7 @@ namespace runtime {
|
||||||
this->_factory = factory;
|
this->_factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::shared_ptr<TokenFactory<CommonToken>> getTokenFactory() override;
|
virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the char stream and reset the lexer </summary>
|
/// Set the char stream and reset the lexer </summary>
|
||||||
|
@ -154,7 +148,7 @@ namespace runtime {
|
||||||
/// and getToken (to push tokens into a list and pull from that list
|
/// and getToken (to push tokens into a list and pull from that list
|
||||||
/// rather than a single variable as this implementation does).
|
/// rather than a single variable as this implementation does).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void emit(Token::Ref token);
|
virtual void emit(Ref<Token> token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The standard method called to automatically emit a token at the
|
/// The standard method called to automatically emit a token at the
|
||||||
|
@ -163,9 +157,9 @@ namespace runtime {
|
||||||
/// use that to set the token's text. Override this method to emit
|
/// use that to set the token's text. Override this method to emit
|
||||||
/// custom Token objects or provide a new factory.
|
/// custom Token objects or provide a new factory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual Token::Ref emit();
|
virtual Ref<Token> emit();
|
||||||
|
|
||||||
virtual Token::Ref emitEOF();
|
virtual Ref<Token> emitEOF();
|
||||||
|
|
||||||
virtual size_t getLine() const override;
|
virtual size_t getLine() const override;
|
||||||
|
|
||||||
|
@ -193,9 +187,9 @@ namespace runtime {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Override if emitting multiple tokens. </summary>
|
/// Override if emitting multiple tokens. </summary>
|
||||||
virtual Token::Ref getToken();
|
virtual Ref<Token> getToken();
|
||||||
|
|
||||||
virtual void setToken(Token::Ref token);
|
virtual void setToken(Ref<Token> token);
|
||||||
|
|
||||||
virtual void setType(int ttype);
|
virtual void setType(int ttype);
|
||||||
|
|
||||||
|
@ -209,7 +203,7 @@ namespace runtime {
|
||||||
|
|
||||||
/// Return a list of all Token objects in input char stream.
|
/// Return a list of all Token objects in input char stream.
|
||||||
/// Forces load of all tokens. Does not include EOF token.
|
/// Forces load of all tokens. Does not include EOF token.
|
||||||
virtual std::vector<Token::Ref> getAllTokens();
|
virtual std::vector<Ref<Token>> getAllTokens();
|
||||||
|
|
||||||
virtual void recover(const LexerNoViableAltException &e);
|
virtual void recover(const LexerNoViableAltException &e);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace runtime {
|
||||||
const std::vector<std::wstring> &_modeNames;
|
const std::vector<std::wstring> &_modeNames;
|
||||||
std::vector<dfa::DFA> _decisionToDFA;
|
std::vector<dfa::DFA> _decisionToDFA;
|
||||||
|
|
||||||
std::shared_ptr<atn::PredictionContextCache> _sharedContextCache;
|
Ref<atn::PredictionContextCache> _sharedContextCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
LexerNoViableAltException::LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex,
|
LexerNoViableAltException::LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex,
|
||||||
std::shared_ptr<atn::ATNConfigSet> deadEndConfigs)
|
Ref<atn::ATNConfigSet> deadEndConfigs)
|
||||||
: RecognitionException(lexer, input, nullptr, nullptr), _startIndex(startIndex), _deadEndConfigs(deadEndConfigs) {
|
: RecognitionException(lexer, input, nullptr, nullptr), _startIndex(startIndex), _deadEndConfigs(deadEndConfigs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ size_t LexerNoViableAltException::getStartIndex() {
|
||||||
return _startIndex;
|
return _startIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<atn::ATNConfigSet> LexerNoViableAltException::getDeadEndConfigs() {
|
Ref<atn::ATNConfigSet> LexerNoViableAltException::getDeadEndConfigs() {
|
||||||
return _deadEndConfigs;
|
return _deadEndConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,10 @@ namespace runtime {
|
||||||
class LexerNoViableAltException : public RecognitionException {
|
class LexerNoViableAltException : public RecognitionException {
|
||||||
public:
|
public:
|
||||||
LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex,
|
LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex,
|
||||||
std::shared_ptr<atn::ATNConfigSet> deadEndConfigs);
|
Ref<atn::ATNConfigSet> deadEndConfigs);
|
||||||
|
|
||||||
virtual size_t getStartIndex();
|
virtual size_t getStartIndex();
|
||||||
virtual std::shared_ptr<atn::ATNConfigSet> getDeadEndConfigs();
|
virtual Ref<atn::ATNConfigSet> getDeadEndConfigs();
|
||||||
virtual std::wstring toString();
|
virtual std::wstring toString();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -53,7 +53,7 @@ namespace runtime {
|
||||||
const size_t _startIndex;
|
const size_t _startIndex;
|
||||||
|
|
||||||
/// Which configurations did we try at input.index() that couldn't match input.LA(1)?
|
/// Which configurations did we try at input.index() that couldn't match input.LA(1)?
|
||||||
std::shared_ptr<atn::ATNConfigSet> _deadEndConfigs;
|
Ref<atn::ATNConfigSet> _deadEndConfigs;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ int ListTokenSource::getCharPositionInLine() {
|
||||||
} else if (tokens.size() > 0) {
|
} else if (tokens.size() > 0) {
|
||||||
// have to calculate the result from the line/column of the previous
|
// have to calculate the result from the line/column of the previous
|
||||||
// token, along with the text of the token.
|
// token, along with the text of the token.
|
||||||
Token::Ref lastToken = tokens.back();
|
Ref<Token> lastToken = tokens.back();
|
||||||
std::wstring tokenText = lastToken->getText();
|
std::wstring tokenText = lastToken->getText();
|
||||||
if (tokenText != L"") {
|
if (tokenText != L"") {
|
||||||
int lastNewLine = (int)tokenText.rfind(L'\n');
|
int lastNewLine = (int)tokenText.rfind(L'\n');
|
||||||
|
@ -62,7 +62,7 @@ int ListTokenSource::getCharPositionInLine() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref ListTokenSource::nextToken() {
|
Ref<Token> ListTokenSource::nextToken() {
|
||||||
if (i >= tokens.size()) {
|
if (i >= tokens.size()) {
|
||||||
if (eofToken == nullptr) {
|
if (eofToken == nullptr) {
|
||||||
int start = -1;
|
int start = -1;
|
||||||
|
@ -81,7 +81,7 @@ Token::Ref ListTokenSource::nextToken() {
|
||||||
return eofToken;
|
return eofToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref t = tokens[i];
|
Ref<Token> t = tokens[i];
|
||||||
if (i == tokens.size() - 1 && t->getType() == EOF) {
|
if (i == tokens.size() - 1 && t->getType() == EOF) {
|
||||||
eofToken = t;
|
eofToken = t;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ size_t ListTokenSource::getLine() const {
|
||||||
} else if (tokens.size() > 0) {
|
} else if (tokens.size() > 0) {
|
||||||
// have to calculate the result from the line/column of the previous
|
// have to calculate the result from the line/column of the previous
|
||||||
// token, along with the text of the token.
|
// token, along with the text of the token.
|
||||||
Token::Ref lastToken = tokens.back();
|
Ref<Token> lastToken = tokens.back();
|
||||||
int line = lastToken->getLine();
|
int line = lastToken->getLine();
|
||||||
|
|
||||||
std::wstring tokenText = lastToken->getText();
|
std::wstring tokenText = lastToken->getText();
|
||||||
|
@ -145,7 +145,7 @@ std::string ListTokenSource::getSourceName() {
|
||||||
return "List";
|
return "List";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TokenFactory<CommonToken>> ListTokenSource::getTokenFactory() {
|
Ref<TokenFactory<CommonToken>> ListTokenSource::getTokenFactory() {
|
||||||
return _factory;
|
return _factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace runtime {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ListTokenSource : public TokenSource {
|
class ListTokenSource : public TokenSource {
|
||||||
protected:
|
protected:
|
||||||
const std::vector<Token::Ref> tokens;
|
const std::vector<Ref<Token>> tokens;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the input source. If this value is {@code null}, a call to
|
/// The name of the input source. If this value is {@code null}, a call to
|
||||||
|
@ -71,14 +71,14 @@ namespace runtime {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This field caches the EOF token for the token source.
|
/// This field caches the EOF token for the token source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Token::Ref eofToken;
|
Ref<Token> eofToken;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the backing field for <seealso cref="#getTokenFactory"/> and
|
/// This is the backing field for <seealso cref="#getTokenFactory"/> and
|
||||||
/// <seealso cref="setTokenFactory"/>.
|
/// <seealso cref="setTokenFactory"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<TokenFactory<CommonToken>> _factory = CommonTokenFactory::DEFAULT;
|
Ref<TokenFactory<CommonToken>> _factory = CommonTokenFactory::DEFAULT;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified
|
/// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified
|
||||||
|
@ -115,7 +115,7 @@ namespace runtime {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getCharPositionInLine() override;
|
virtual int getCharPositionInLine() override;
|
||||||
virtual Token::Ref nextToken() override;
|
virtual Ref<Token> nextToken() override;
|
||||||
virtual size_t getLine() const override;
|
virtual size_t getLine() const override;
|
||||||
virtual CharStream* getInputStream() override;
|
virtual CharStream* getInputStream() override;
|
||||||
virtual std::string getSourceName() override;
|
virtual std::string getSourceName() override;
|
||||||
|
@ -125,7 +125,7 @@ namespace runtime {
|
||||||
this->_factory = factory;
|
this->_factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::shared_ptr<TokenFactory<CommonToken>> getTokenFactory() override;
|
virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeInstanceFields();
|
void InitializeInstanceFields();
|
||||||
|
|
|
@ -40,15 +40,15 @@ NoViableAltException::NoViableAltException(Parser *recognizer)
|
||||||
recognizer->getCurrentToken(), nullptr, recognizer->getContext()) {
|
recognizer->getCurrentToken(), nullptr, recognizer->getContext()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NoViableAltException::NoViableAltException(Parser *recognizer, TokenStream *input, Token::Ref startToken,
|
NoViableAltException::NoViableAltException(Parser *recognizer, TokenStream *input, Ref<Token> startToken,
|
||||||
Token::Ref offendingToken, std::shared_ptr<atn::ATNConfigSet> deadEndConfigs, ParserRuleContext::Ref ctx)
|
Ref<Token> offendingToken, Ref<atn::ATNConfigSet> deadEndConfigs, Ref<ParserRuleContext> ctx)
|
||||||
: RecognitionException(recognizer, input, ctx, offendingToken), _deadEndConfigs(deadEndConfigs), _startToken(startToken) {
|
: RecognitionException(recognizer, input, ctx, offendingToken), _deadEndConfigs(deadEndConfigs), _startToken(startToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref NoViableAltException::getStartToken() const {
|
Ref<Token> NoViableAltException::getStartToken() const {
|
||||||
return _startToken;
|
return _startToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<atn::ATNConfigSet> NoViableAltException::getDeadEndConfigs() const {
|
Ref<atn::ATNConfigSet> NoViableAltException::getDeadEndConfigs() const {
|
||||||
return _deadEndConfigs;
|
return _deadEndConfigs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,11 @@ namespace runtime {
|
||||||
class NoViableAltException : public RecognitionException {
|
class NoViableAltException : public RecognitionException {
|
||||||
public:
|
public:
|
||||||
NoViableAltException(Parser *recognizer); // LL(1) error
|
NoViableAltException(Parser *recognizer); // LL(1) error
|
||||||
NoViableAltException(Parser *recognizer, TokenStream *input, Token::Ref startToken, Token::Ref offendingToken,
|
NoViableAltException(Parser *recognizer, TokenStream *input, Ref<Token> startToken, Ref<Token> offendingToken,
|
||||||
std::shared_ptr<atn::ATNConfigSet> deadEndConfigs, ParserRuleContext::Ref ctx);
|
Ref<atn::ATNConfigSet> deadEndConfigs, Ref<ParserRuleContext> ctx);
|
||||||
|
|
||||||
virtual Token::Ref getStartToken() const;
|
virtual Ref<Token> getStartToken() const;
|
||||||
virtual std::shared_ptr<atn::ATNConfigSet> getDeadEndConfigs() const;
|
virtual Ref<atn::ATNConfigSet> getDeadEndConfigs() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Which configurations did we try at input.index() that couldn't match input.LT(1)?
|
/// Which configurations did we try at input.index() that couldn't match input.LT(1)?
|
||||||
|
@ -61,7 +61,7 @@ namespace runtime {
|
||||||
/// not be buffering tokens so get a reference to it. (At the
|
/// not be buffering tokens so get a reference to it. (At the
|
||||||
/// time the error occurred, of course the stream needs to keep a
|
/// time the error occurred, of course the stream needs to keep a
|
||||||
/// buffer all of the tokens but later we might not have access to those.)
|
/// buffer all of the tokens but later we might not have access to those.)
|
||||||
Token::Ref _startToken;
|
Ref<Token> _startToken;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,9 @@
|
||||||
#include "ANTLRErrorListener.h"
|
#include "ANTLRErrorListener.h"
|
||||||
#include "ParseTreePattern.h"
|
#include "ParseTreePattern.h"
|
||||||
|
|
||||||
|
#include "ProfilingATNSimulator.h"
|
||||||
|
#include "ParseInfo.h"
|
||||||
|
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
@ -57,43 +60,43 @@ std::map<std::wstring, atn::ATN> Parser::bypassAltsAtnCache;
|
||||||
Parser::TraceListener::TraceListener(Parser *outerInstance) : outerInstance(outerInstance) {
|
Parser::TraceListener::TraceListener(Parser *outerInstance) : outerInstance(outerInstance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TraceListener::enterEveryRule(ParserRuleContext::Ref ctx) {
|
void Parser::TraceListener::enterEveryRule(Ref<ParserRuleContext> ctx) {
|
||||||
std::cout << "enter "
|
std::cout << "enter "
|
||||||
<< antlrcpp::ws2s(outerInstance->getRuleNames()[(size_t)ctx->getRuleIndex()])
|
<< antlrcpp::ws2s(outerInstance->getRuleNames()[(size_t)ctx->getRuleIndex()])
|
||||||
<< ", LT(1)=" << antlrcpp::ws2s(outerInstance->_input->LT(1)->getText())
|
<< ", LT(1)=" << antlrcpp::ws2s(outerInstance->_input->LT(1)->getText())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TraceListener::visitTerminal(std::shared_ptr<tree::TerminalNode> node) {
|
void Parser::TraceListener::visitTerminal(Ref<tree::TerminalNode> node) {
|
||||||
std::cout << "consume "
|
std::cout << "consume "
|
||||||
<< node->getSymbol() << " rule "
|
<< node->getSymbol() << " rule "
|
||||||
<< antlrcpp::ws2s(outerInstance->getRuleNames()[(size_t)outerInstance->getContext()->getRuleIndex()])
|
<< antlrcpp::ws2s(outerInstance->getRuleNames()[(size_t)outerInstance->getContext()->getRuleIndex()])
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TraceListener::visitErrorNode(std::shared_ptr<tree::ErrorNode> node) {
|
void Parser::TraceListener::visitErrorNode(Ref<tree::ErrorNode> node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TraceListener::exitEveryRule(ParserRuleContext::Ref ctx) {
|
void Parser::TraceListener::exitEveryRule(Ref<ParserRuleContext> ctx) {
|
||||||
std::cout << "exit "
|
std::cout << "exit "
|
||||||
<< antlrcpp::ws2s(outerInstance->getRuleNames()[(size_t)ctx->getRuleIndex()])
|
<< antlrcpp::ws2s(outerInstance->getRuleNames()[(size_t)ctx->getRuleIndex()])
|
||||||
<< ", LT(1)=" << antlrcpp::ws2s(outerInstance->_input->LT(1)->getText())
|
<< ", LT(1)=" << antlrcpp::ws2s(outerInstance->_input->LT(1)->getText())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::shared_ptr<Parser::TrimToSizeListener> Parser::TrimToSizeListener::INSTANCE =
|
const Ref<Parser::TrimToSizeListener> Parser::TrimToSizeListener::INSTANCE =
|
||||||
std::make_shared<Parser::TrimToSizeListener>();
|
std::make_shared<Parser::TrimToSizeListener>();
|
||||||
|
|
||||||
void Parser::TrimToSizeListener::enterEveryRule(ParserRuleContext::Ref ctx) {
|
void Parser::TrimToSizeListener::enterEveryRule(Ref<ParserRuleContext> ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TrimToSizeListener::visitTerminal(std::shared_ptr<tree::TerminalNode> node) {
|
void Parser::TrimToSizeListener::visitTerminal(Ref<tree::TerminalNode> node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TrimToSizeListener::visitErrorNode(std::shared_ptr<tree::ErrorNode> node) {
|
void Parser::TrimToSizeListener::visitErrorNode(Ref<tree::ErrorNode> node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::TrimToSizeListener::exitEveryRule(ParserRuleContext::Ref ctx) {
|
void Parser::TrimToSizeListener::exitEveryRule(Ref<ParserRuleContext> ctx) {
|
||||||
ctx->children.shrink_to_fit();
|
ctx->children.shrink_to_fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,9 +124,12 @@ void Parser::reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Parser::match(int ttype) {
|
Ref<Token> Parser::match(int ttype) {
|
||||||
Token::Ref t = getCurrentToken();
|
Ref<Token> t = getCurrentToken();
|
||||||
if (t->getType() == ttype) {
|
if (t->getType() == ttype) {
|
||||||
|
if (ttype == EOF) {
|
||||||
|
_matchedEOF = true;
|
||||||
|
}
|
||||||
_errHandler->reportMatch(this);
|
_errHandler->reportMatch(this);
|
||||||
consume();
|
consume();
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,8 +143,8 @@ Token::Ref Parser::match(int ttype) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Parser::matchWildcard() {
|
Ref<Token> Parser::matchWildcard() {
|
||||||
Token::Ref t = getCurrentToken();
|
Ref<Token> t = getCurrentToken();
|
||||||
if (t->getType() > 0) {
|
if (t->getType() > 0) {
|
||||||
_errHandler->reportMatch(this);
|
_errHandler->reportMatch(this);
|
||||||
consume();
|
consume();
|
||||||
|
@ -177,11 +183,11 @@ bool Parser::getTrimParseTree() {
|
||||||
return std::find(getParseListeners().begin(), getParseListeners().end(), TrimToSizeListener::INSTANCE) != getParseListeners().end();
|
return std::find(getParseListeners().begin(), getParseListeners().end(), TrimToSizeListener::INSTANCE) != getParseListeners().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<tree::ParseTreeListener>> Parser::getParseListeners() {
|
std::vector<Ref<tree::ParseTreeListener>> Parser::getParseListeners() {
|
||||||
return _parseListeners;
|
return _parseListeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::addParseListener(std::shared_ptr<tree::ParseTreeListener> listener) {
|
void Parser::addParseListener(Ref<tree::ParseTreeListener> listener) {
|
||||||
if (!listener) {
|
if (!listener) {
|
||||||
throw NullPointerException("listener");
|
throw NullPointerException("listener");
|
||||||
}
|
}
|
||||||
|
@ -189,7 +195,7 @@ void Parser::addParseListener(std::shared_ptr<tree::ParseTreeListener> listener)
|
||||||
this->_parseListeners.push_back(listener);
|
this->_parseListeners.push_back(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::removeParseListener(std::shared_ptr<tree::ParseTreeListener> listener) {
|
void Parser::removeParseListener(Ref<tree::ParseTreeListener> listener) {
|
||||||
if (!_parseListeners.empty()) {
|
if (!_parseListeners.empty()) {
|
||||||
auto it = std::find(_parseListeners.begin(), _parseListeners.end(), listener);
|
auto it = std::find(_parseListeners.begin(), _parseListeners.end(), listener);
|
||||||
if (it != _parseListeners.end()) {
|
if (it != _parseListeners.end()) {
|
||||||
|
@ -221,7 +227,7 @@ int Parser::getNumberOfSyntaxErrors() {
|
||||||
return _syntaxErrors;
|
return _syntaxErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TokenFactory<CommonToken>> Parser::getTokenFactory() {
|
Ref<TokenFactory<CommonToken>> Parser::getTokenFactory() {
|
||||||
return _input->getTokenSource()->getTokenFactory();
|
return _input->getTokenSource()->getTokenFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,11 +271,11 @@ tree::pattern::ParseTreePattern Parser::compileParseTreePattern(const std::wstri
|
||||||
return m.compile(pattern, patternRuleIndex);
|
return m.compile(pattern, patternRuleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ANTLRErrorStrategy> Parser::getErrorHandler() {
|
Ref<ANTLRErrorStrategy> Parser::getErrorHandler() {
|
||||||
return _errHandler;
|
return _errHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::setErrorHandler(std::shared_ptr<ANTLRErrorStrategy> handler) {
|
void Parser::setErrorHandler(Ref<ANTLRErrorStrategy> handler) {
|
||||||
_errHandler = handler;
|
_errHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +297,7 @@ void Parser::setTokenStream(TokenStream *input) {
|
||||||
_input = input;
|
_input = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Parser::getCurrentToken() {
|
Ref<Token> Parser::getCurrentToken() {
|
||||||
return _input->LT(1);
|
return _input->LT(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +305,7 @@ void Parser::notifyErrorListeners(const std::wstring &msg) {
|
||||||
notifyErrorListeners(getCurrentToken(), msg, nullptr);
|
notifyErrorListeners(getCurrentToken(), msg, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::notifyErrorListeners(Token::Ref offendingToken, const std::wstring &msg, std::exception_ptr e) {
|
void Parser::notifyErrorListeners(Ref<Token> offendingToken, const std::wstring &msg, std::exception_ptr e) {
|
||||||
_syntaxErrors++;
|
_syntaxErrors++;
|
||||||
int line = -1;
|
int line = -1;
|
||||||
int charPositionInLine = -1;
|
int charPositionInLine = -1;
|
||||||
|
@ -310,22 +316,22 @@ void Parser::notifyErrorListeners(Token::Ref offendingToken, const std::wstring
|
||||||
listener.syntaxError(this, offendingToken, (size_t)line, charPositionInLine, msg, e);
|
listener.syntaxError(this, offendingToken, (size_t)line, charPositionInLine, msg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref Parser::consume() {
|
Ref<Token> Parser::consume() {
|
||||||
Token::Ref o = getCurrentToken();
|
Ref<Token> o = getCurrentToken();
|
||||||
if (o->getType() != EOF) {
|
if (o->getType() != EOF) {
|
||||||
getInputStream()->consume();
|
getInputStream()->consume();
|
||||||
}
|
}
|
||||||
bool hasListener = _parseListeners.size() > 0 && !_parseListeners.empty();
|
bool hasListener = _parseListeners.size() > 0 && !_parseListeners.empty();
|
||||||
if (_buildParseTrees || hasListener) {
|
if (_buildParseTrees || hasListener) {
|
||||||
if (_errHandler->inErrorRecoveryMode(this)) {
|
if (_errHandler->inErrorRecoveryMode(this)) {
|
||||||
std::shared_ptr<tree::ErrorNode> node = _ctx->addErrorNode(o);
|
Ref<tree::ErrorNode> node = _ctx->addErrorNode(o);
|
||||||
if (_parseListeners.size() > 0) {
|
if (_parseListeners.size() > 0) {
|
||||||
for (auto listener : _parseListeners) {
|
for (auto listener : _parseListeners) {
|
||||||
listener->visitErrorNode(node);
|
listener->visitErrorNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::shared_ptr<tree::TerminalNode> node = _ctx->addChild(o);
|
Ref<tree::TerminalNode> node = _ctx->addChild(o);
|
||||||
if (_parseListeners.size() > 0) {
|
if (_parseListeners.size() > 0) {
|
||||||
for (auto listener : _parseListeners) {
|
for (auto listener : _parseListeners) {
|
||||||
listener->visitTerminal(node);
|
listener->visitTerminal(node);
|
||||||
|
@ -341,11 +347,11 @@ void Parser::addContextToParseTree() {
|
||||||
if (_ctx->parent.expired())
|
if (_ctx->parent.expired())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ParserRuleContext::Ref parent = std::dynamic_pointer_cast<ParserRuleContext>(_ctx->parent.lock());
|
Ref<ParserRuleContext> parent = std::dynamic_pointer_cast<ParserRuleContext>(_ctx->parent.lock());
|
||||||
parent->addChild(_ctx);
|
parent->addChild(_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::enterRule(ParserRuleContext::Ref localctx, int state, int ruleIndex) {
|
void Parser::enterRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex) {
|
||||||
setState(state);
|
setState(state);
|
||||||
_ctx = localctx;
|
_ctx = localctx;
|
||||||
_ctx->start = _input->LT(1);
|
_ctx->start = _input->LT(1);
|
||||||
|
@ -358,6 +364,13 @@ void Parser::enterRule(ParserRuleContext::Ref localctx, int state, int ruleIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::exitRule() {
|
void Parser::exitRule() {
|
||||||
|
if (_matchedEOF) {
|
||||||
|
// if we have matched EOF, it cannot consume past EOF so we use LT(1) here
|
||||||
|
_ctx->stop = _input->LT(1); // LT(1) will be end of file
|
||||||
|
} else {
|
||||||
|
_ctx->stop = _input->LT(-1); // stop node is what we just matched
|
||||||
|
}
|
||||||
|
|
||||||
_ctx->stop = _input->LT(-1);
|
_ctx->stop = _input->LT(-1);
|
||||||
// trigger event on ctx, before it reverts to parent
|
// trigger event on ctx, before it reverts to parent
|
||||||
if (_parseListeners.size() > 0) {
|
if (_parseListeners.size() > 0) {
|
||||||
|
@ -367,12 +380,14 @@ void Parser::exitRule() {
|
||||||
_ctx = std::dynamic_pointer_cast<ParserRuleContext>(_ctx->parent.lock());
|
_ctx = std::dynamic_pointer_cast<ParserRuleContext>(_ctx->parent.lock());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::enterOuterAlt(ParserRuleContext::Ref localctx, int altNum) {
|
void Parser::enterOuterAlt(Ref<ParserRuleContext> localctx, int altNum) {
|
||||||
|
localctx->setAltNumber(altNum);
|
||||||
|
|
||||||
// if we have new localctx, make sure we replace existing ctx
|
// if we have new localctx, make sure we replace existing ctx
|
||||||
// that is previous child of parse tree
|
// that is previous child of parse tree
|
||||||
if (_buildParseTrees && _ctx != localctx) {
|
if (_buildParseTrees && _ctx != localctx) {
|
||||||
if (!_ctx->parent.expired()) {
|
if (!_ctx->parent.expired()) {
|
||||||
ParserRuleContext::Ref parent = std::dynamic_pointer_cast<ParserRuleContext>(_ctx->parent.lock());
|
Ref<ParserRuleContext> parent = std::dynamic_pointer_cast<ParserRuleContext>(_ctx->parent.lock());
|
||||||
parent->removeLastChild();
|
parent->removeLastChild();
|
||||||
parent->addChild(localctx);
|
parent->addChild(localctx);
|
||||||
}
|
}
|
||||||
|
@ -380,11 +395,19 @@ void Parser::enterOuterAlt(ParserRuleContext::Ref localctx, int altNum) {
|
||||||
_ctx = localctx;
|
_ctx = localctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::enterRecursionRule(ParserRuleContext::Ref localctx, int ruleIndex) {
|
int Parser::getPrecedence() const {
|
||||||
|
if (_precedenceStack.empty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _precedenceStack.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Parser::enterRecursionRule(Ref<ParserRuleContext> localctx, int ruleIndex) {
|
||||||
enterRecursionRule(localctx, getATN().ruleToStartState[(size_t)ruleIndex]->stateNumber, ruleIndex, 0);
|
enterRecursionRule(localctx, getATN().ruleToStartState[(size_t)ruleIndex]->stateNumber, ruleIndex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::enterRecursionRule(ParserRuleContext::Ref localctx, int state, int ruleIndex, int precedence) {
|
void Parser::enterRecursionRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex, int precedence) {
|
||||||
setState(state);
|
setState(state);
|
||||||
_precedenceStack.push_back(precedence);
|
_precedenceStack.push_back(precedence);
|
||||||
_ctx = localctx;
|
_ctx = localctx;
|
||||||
|
@ -394,8 +417,8 @@ void Parser::enterRecursionRule(ParserRuleContext::Ref localctx, int state, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::pushNewRecursionContext(ParserRuleContext::Ref localctx, int state, int ruleIndex) {
|
void Parser::pushNewRecursionContext(Ref<ParserRuleContext> localctx, int state, int ruleIndex) {
|
||||||
ParserRuleContext::Ref previous = _ctx;
|
Ref<ParserRuleContext> previous = _ctx;
|
||||||
previous->parent = localctx;
|
previous->parent = localctx;
|
||||||
previous->invokingState = state;
|
previous->invokingState = state;
|
||||||
previous->stop = _input->LT(-1);
|
previous->stop = _input->LT(-1);
|
||||||
|
@ -411,10 +434,10 @@ void Parser::pushNewRecursionContext(ParserRuleContext::Ref localctx, int state,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::unrollRecursionContexts(ParserRuleContext::Ref parentctx) {
|
void Parser::unrollRecursionContexts(Ref<ParserRuleContext> parentctx) {
|
||||||
_precedenceStack.pop_back();
|
_precedenceStack.pop_back();
|
||||||
_ctx->stop = _input->LT(-1);
|
_ctx->stop = _input->LT(-1);
|
||||||
ParserRuleContext::Ref retctx = _ctx; // save current ctx (return value)
|
Ref<ParserRuleContext> retctx = _ctx; // save current ctx (return value)
|
||||||
|
|
||||||
// unroll so ctx is as it was before call to recursive method
|
// unroll so ctx is as it was before call to recursive method
|
||||||
if (_parseListeners.size() > 0) {
|
if (_parseListeners.size() > 0) {
|
||||||
|
@ -435,8 +458,8 @@ void Parser::unrollRecursionContexts(ParserRuleContext::Ref parentctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserRuleContext::Ref Parser::getInvokingContext(int ruleIndex) {
|
Ref<ParserRuleContext> Parser::getInvokingContext(int ruleIndex) {
|
||||||
ParserRuleContext::Ref p = _ctx;
|
Ref<ParserRuleContext> p = _ctx;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (p->getRuleIndex() == ruleIndex) {
|
if (p->getRuleIndex() == ruleIndex) {
|
||||||
return p;
|
return p;
|
||||||
|
@ -445,18 +468,18 @@ ParserRuleContext::Ref Parser::getInvokingContext(int ruleIndex) {
|
||||||
break;
|
break;
|
||||||
p = std::dynamic_pointer_cast<ParserRuleContext>(p->parent.lock());
|
p = std::dynamic_pointer_cast<ParserRuleContext>(p->parent.lock());
|
||||||
}
|
}
|
||||||
return ParserRuleContext::Ref();
|
return Ref<ParserRuleContext>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserRuleContext::Ref Parser::getContext() {
|
Ref<ParserRuleContext> Parser::getContext() {
|
||||||
return _ctx;
|
return _ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::setContext(ParserRuleContext::Ref ctx) {
|
void Parser::setContext(Ref<ParserRuleContext> ctx) {
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::precpred(RuleContext::Ref localctx, int precedence) {
|
bool Parser::precpred(Ref<RuleContext> localctx, int precedence) {
|
||||||
return precedence >= _precedenceStack.back();
|
return precedence >= _precedenceStack.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +490,7 @@ bool Parser::inContext(const std::wstring &context) {
|
||||||
|
|
||||||
bool Parser::isExpectedToken(int symbol) {
|
bool Parser::isExpectedToken(int symbol) {
|
||||||
const atn::ATN &atn = getInterpreter<atn::ParserATNSimulator>()->atn;
|
const atn::ATN &atn = getInterpreter<atn::ParserATNSimulator>()->atn;
|
||||||
ParserRuleContext::Ref ctx = _ctx;
|
Ref<ParserRuleContext> ctx = _ctx;
|
||||||
atn::ATNState *s = atn.states[(size_t)getState()];
|
atn::ATNState *s = atn.states[(size_t)getState()];
|
||||||
misc::IntervalSet following = atn.nextTokens(s);
|
misc::IntervalSet following = atn.nextTokens(s);
|
||||||
|
|
||||||
|
@ -497,6 +520,10 @@ bool Parser::isExpectedToken(int symbol) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Parser::isMatchedEOF() const {
|
||||||
|
return _matchedEOF;
|
||||||
|
}
|
||||||
|
|
||||||
misc::IntervalSet Parser::getExpectedTokens() {
|
misc::IntervalSet Parser::getExpectedTokens() {
|
||||||
return getATN().getExpectedTokens(getState(), getContext());
|
return getATN().getExpectedTokens(getState(), getContext());
|
||||||
}
|
}
|
||||||
|
@ -516,7 +543,7 @@ ssize_t Parser::getRuleIndex(const std::wstring &ruleName) {
|
||||||
return iterator->second;
|
return iterator->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserRuleContext::Ref Parser::getRuleContext() {
|
Ref<ParserRuleContext> Parser::getRuleContext() {
|
||||||
return _ctx;
|
return _ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +551,7 @@ std::vector<std::wstring> Parser::getRuleInvocationStack() {
|
||||||
return getRuleInvocationStack(_ctx);
|
return getRuleInvocationStack(_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::wstring> Parser::getRuleInvocationStack(RuleContext::Ref p) {
|
std::vector<std::wstring> Parser::getRuleInvocationStack(Ref<RuleContext> p) {
|
||||||
std::vector<std::wstring> ruleNames = getRuleNames();
|
std::vector<std::wstring> ruleNames = getRuleNames();
|
||||||
std::vector<std::wstring> stack = std::vector<std::wstring>();
|
std::vector<std::wstring> stack = std::vector<std::wstring>();
|
||||||
while (p) {
|
while (p) {
|
||||||
|
@ -544,13 +571,13 @@ std::vector<std::wstring> Parser::getRuleInvocationStack(RuleContext::Ref p) {
|
||||||
|
|
||||||
std::vector<std::wstring> Parser::getDFAStrings() {
|
std::vector<std::wstring> Parser::getDFAStrings() {
|
||||||
atn::ParserATNSimulator *simulator = getInterpreter<atn::ParserATNSimulator>();
|
atn::ParserATNSimulator *simulator = getInterpreter<atn::ParserATNSimulator>();
|
||||||
if (!simulator->_decisionToDFA.empty()) {
|
if (!simulator->decisionToDFA.empty()) {
|
||||||
std::lock_guard<std::mutex> lck(mtx);
|
std::lock_guard<std::mutex> lck(mtx);
|
||||||
|
|
||||||
std::vector<std::wstring> s;
|
std::vector<std::wstring> s;
|
||||||
for (size_t d = 0; d < simulator->_decisionToDFA.size(); d++) {
|
for (size_t d = 0; d < simulator->decisionToDFA.size(); d++) {
|
||||||
dfa::DFA &dfa = simulator->_decisionToDFA[d];
|
dfa::DFA &dfa = simulator->decisionToDFA[d];
|
||||||
s.push_back(dfa.toString(getTokenNames()));
|
s.push_back(dfa.toString(getVocabulary()));
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -559,18 +586,18 @@ std::vector<std::wstring> Parser::getDFAStrings() {
|
||||||
|
|
||||||
void Parser::dumpDFA() {
|
void Parser::dumpDFA() {
|
||||||
atn::ParserATNSimulator *simulator = getInterpreter<atn::ParserATNSimulator>();
|
atn::ParserATNSimulator *simulator = getInterpreter<atn::ParserATNSimulator>();
|
||||||
if (!simulator->_decisionToDFA.empty()) {
|
if (!simulator->decisionToDFA.empty()) {
|
||||||
std::lock_guard<std::mutex> lck(mtx);
|
std::lock_guard<std::mutex> lck(mtx);
|
||||||
bool seenOne = false;
|
bool seenOne = false;
|
||||||
for (size_t d = 0; d < simulator->_decisionToDFA.size(); d++) {
|
for (size_t d = 0; d < simulator->decisionToDFA.size(); d++) {
|
||||||
dfa::DFA &dfa = simulator->_decisionToDFA[d];
|
dfa::DFA &dfa = simulator->decisionToDFA[d];
|
||||||
if (!dfa.states.empty()) {
|
if (!dfa.states.empty()) {
|
||||||
if (seenOne) {
|
if (seenOne) {
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << L"Decision " << dfa.decision << L":" << std::endl;
|
std::cout << L"Decision " << dfa.decision << L":" << std::endl;
|
||||||
dfa.toString(getTokenNames());
|
dfa.toString(getTokenNames());
|
||||||
std::wcout << dfa.toString(getTokenNames());
|
std::wcout << dfa.toString(getVocabulary());
|
||||||
seenOne = true;
|
seenOne = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,6 +608,29 @@ std::string Parser::getSourceName() {
|
||||||
return _input->getSourceName();
|
return _input->getSourceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<atn::ParseInfo> Parser::getParseInfo() const {
|
||||||
|
atn::ProfilingATNSimulator *interp = getInterpreter<atn::ProfilingATNSimulator>();
|
||||||
|
if (interp != nullptr) {
|
||||||
|
return std::make_shared<atn::ParseInfo>(interp);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Parser::setProfile(bool profile) {
|
||||||
|
atn::ParserATNSimulator *interp = getInterpreter<atn::ProfilingATNSimulator>();
|
||||||
|
atn::PredictionMode saveMode = interp->getPredictionMode();
|
||||||
|
if (profile) {
|
||||||
|
if (!is<atn::ProfilingATNSimulator *>(interp)) {
|
||||||
|
setInterpreter(new atn::ProfilingATNSimulator(this)); /* mem-check: replacing existing interpreter which gets deleted. */
|
||||||
|
}
|
||||||
|
} else if (is<atn::ProfilingATNSimulator *>(interp)) {
|
||||||
|
/* mem-check: replacing existing interpreter which gets deleted. */
|
||||||
|
atn::ParserATNSimulator *sim = new atn::ParserATNSimulator(this, getATN(), interp->decisionToDFA, interp->getSharedContextCache());
|
||||||
|
setInterpreter(sim);
|
||||||
|
}
|
||||||
|
getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(saveMode);
|
||||||
|
}
|
||||||
|
|
||||||
void Parser::setTrace(bool trace) {
|
void Parser::setTrace(bool trace) {
|
||||||
if (!trace) {
|
if (!trace) {
|
||||||
if (_tracer)
|
if (_tracer)
|
||||||
|
@ -594,12 +644,17 @@ void Parser::setTrace(bool trace) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Parser::isTrace() const {
|
||||||
|
return _tracer != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Parser::InitializeInstanceFields() {
|
void Parser::InitializeInstanceFields() {
|
||||||
_errHandler = std::make_shared<DefaultErrorStrategy>();
|
_errHandler = std::make_shared<DefaultErrorStrategy>();
|
||||||
_precedenceStack.clear();
|
_precedenceStack.clear();
|
||||||
_precedenceStack.push_back(0);
|
_precedenceStack.push_back(0);
|
||||||
_buildParseTrees = true;
|
_buildParseTrees = true;
|
||||||
_syntaxErrors = 0;
|
_syntaxErrors = 0;
|
||||||
|
_matchedEOF = false;
|
||||||
_input = nullptr;
|
_input = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,10 +51,10 @@ namespace runtime {
|
||||||
TraceListener(Parser *outerInstance);
|
TraceListener(Parser *outerInstance);
|
||||||
virtual ~TraceListener() {};
|
virtual ~TraceListener() {};
|
||||||
|
|
||||||
virtual void enterEveryRule(ParserRuleContext::Ref ctx) override;
|
virtual void enterEveryRule(Ref<ParserRuleContext> ctx) override;
|
||||||
virtual void visitTerminal(std::shared_ptr<tree::TerminalNode> node) override;
|
virtual void visitTerminal(Ref<tree::TerminalNode> node) override;
|
||||||
virtual void visitErrorNode(std::shared_ptr<tree::ErrorNode> node) override;
|
virtual void visitErrorNode(Ref<tree::ErrorNode> node) override;
|
||||||
virtual void exitEveryRule(ParserRuleContext::Ref ctx) override;
|
virtual void exitEveryRule(Ref<ParserRuleContext> ctx) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Parser *const outerInstance;
|
Parser *const outerInstance;
|
||||||
|
@ -62,12 +62,12 @@ namespace runtime {
|
||||||
|
|
||||||
class TrimToSizeListener : public tree::ParseTreeListener {
|
class TrimToSizeListener : public tree::ParseTreeListener {
|
||||||
public:
|
public:
|
||||||
static const std::shared_ptr<TrimToSizeListener> INSTANCE;
|
static const Ref<TrimToSizeListener> INSTANCE;
|
||||||
|
|
||||||
virtual void enterEveryRule(ParserRuleContext::Ref ctx) override;
|
virtual void enterEveryRule(Ref<ParserRuleContext> ctx) override;
|
||||||
virtual void visitTerminal(std::shared_ptr<tree::TerminalNode> node) override;
|
virtual void visitTerminal(Ref<tree::TerminalNode> node) override;
|
||||||
virtual void visitErrorNode(std::shared_ptr<tree::ErrorNode> node) override;
|
virtual void visitErrorNode(Ref<tree::ErrorNode> node) override;
|
||||||
virtual void exitEveryRule(ParserRuleContext::Ref ctx) override;
|
virtual void exitEveryRule(Ref<ParserRuleContext> ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
Parser(TokenStream *input);
|
Parser(TokenStream *input);
|
||||||
|
@ -94,7 +94,7 @@ namespace runtime {
|
||||||
/// <exception cref="RecognitionException"> if the current input symbol did not match
|
/// <exception cref="RecognitionException"> if the current input symbol did not match
|
||||||
/// {@code ttype} and the error strategy could not recover from the
|
/// {@code ttype} and the error strategy could not recover from the
|
||||||
/// mismatched symbol </exception>
|
/// mismatched symbol </exception>
|
||||||
virtual Token::Ref match(int ttype);
|
virtual Ref<Token> match(int ttype);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Match current input symbol as a wildcard. If the symbol type matches
|
/// Match current input symbol as a wildcard. If the symbol type matches
|
||||||
|
@ -112,7 +112,7 @@ namespace runtime {
|
||||||
/// <exception cref="RecognitionException"> if the current input symbol did not match
|
/// <exception cref="RecognitionException"> if the current input symbol did not match
|
||||||
/// a wildcard and the error strategy could not recover from the mismatched
|
/// a wildcard and the error strategy could not recover from the mismatched
|
||||||
/// symbol </exception>
|
/// symbol </exception>
|
||||||
virtual Token::Ref matchWildcard();
|
virtual Ref<Token> matchWildcard();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Track the <seealso cref="ParserRuleContext"/> objects during the parse and hook
|
/// Track the <seealso cref="ParserRuleContext"/> objects during the parse and hook
|
||||||
|
@ -151,7 +151,7 @@ namespace runtime {
|
||||||
/// using the default <seealso cref="Parser.TrimToSizeListener"/> during the parse process. </returns>
|
/// using the default <seealso cref="Parser.TrimToSizeListener"/> during the parse process. </returns>
|
||||||
virtual bool getTrimParseTree();
|
virtual bool getTrimParseTree();
|
||||||
|
|
||||||
virtual std::vector<std::shared_ptr<tree::ParseTreeListener>> getParseListeners();
|
virtual std::vector<Ref<tree::ParseTreeListener>> getParseListeners();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers {@code listener} to receive events during the parsing process.
|
/// Registers {@code listener} to receive events during the parsing process.
|
||||||
|
@ -181,7 +181,7 @@ namespace runtime {
|
||||||
/// <param name="listener"> the listener to add
|
/// <param name="listener"> the listener to add
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <exception cref="NullPointerException"> if {@code} listener is {@code null} </exception>
|
/// <exception cref="NullPointerException"> if {@code} listener is {@code null} </exception>
|
||||||
virtual void addParseListener(std::shared_ptr<tree::ParseTreeListener> listener);
|
virtual void addParseListener(Ref<tree::ParseTreeListener> listener);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove {@code listener} from the list of parse listeners.
|
/// Remove {@code listener} from the list of parse listeners.
|
||||||
|
@ -192,7 +192,7 @@ namespace runtime {
|
||||||
/// <seealso cref= #addParseListener
|
/// <seealso cref= #addParseListener
|
||||||
/// </seealso>
|
/// </seealso>
|
||||||
/// <param name="listener"> the listener to remove </param>
|
/// <param name="listener"> the listener to remove </param>
|
||||||
virtual void removeParseListener(std::shared_ptr<tree::ParseTreeListener> listener);
|
virtual void removeParseListener(Ref<tree::ParseTreeListener> listener);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all parse listeners.
|
/// Remove all parse listeners.
|
||||||
|
@ -219,7 +219,7 @@ namespace runtime {
|
||||||
/// <seealso cref= #notifyErrorListeners </seealso>
|
/// <seealso cref= #notifyErrorListeners </seealso>
|
||||||
virtual int getNumberOfSyntaxErrors();
|
virtual int getNumberOfSyntaxErrors();
|
||||||
|
|
||||||
virtual std::shared_ptr<TokenFactory<CommonToken>> getTokenFactory() override;
|
virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tell our token source and error strategy about a new way to create tokens. </summary>
|
/// Tell our token source and error strategy about a new way to create tokens. </summary>
|
||||||
|
@ -252,8 +252,8 @@ namespace runtime {
|
||||||
virtual tree::pattern::ParseTreePattern compileParseTreePattern(const std::wstring &pattern, int patternRuleIndex,
|
virtual tree::pattern::ParseTreePattern compileParseTreePattern(const std::wstring &pattern, int patternRuleIndex,
|
||||||
Lexer *lexer);
|
Lexer *lexer);
|
||||||
|
|
||||||
virtual std::shared_ptr<ANTLRErrorStrategy> getErrorHandler();
|
virtual Ref<ANTLRErrorStrategy> getErrorHandler();
|
||||||
virtual void setErrorHandler(std::shared_ptr<ANTLRErrorStrategy> handler);
|
virtual void setErrorHandler(Ref<ANTLRErrorStrategy> handler);
|
||||||
|
|
||||||
virtual IntStream* getInputStream() override;
|
virtual IntStream* getInputStream() override;
|
||||||
void setInputStream(IntStream *input) override;
|
void setInputStream(IntStream *input) override;
|
||||||
|
@ -267,11 +267,11 @@ namespace runtime {
|
||||||
/// Match needs to return the current input symbol, which gets put
|
/// Match needs to return the current input symbol, which gets put
|
||||||
/// into the label for the associated token ref; e.g., x=ID.
|
/// into the label for the associated token ref; e.g., x=ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual Token::Ref getCurrentToken();
|
virtual Ref<Token> getCurrentToken();
|
||||||
|
|
||||||
void notifyErrorListeners(const std::wstring &msg);
|
void notifyErrorListeners(const std::wstring &msg);
|
||||||
|
|
||||||
virtual void notifyErrorListeners(Token::Ref offendingToken, const std::wstring &msg, std::exception_ptr e);
|
virtual void notifyErrorListeners(Ref<Token> offendingToken, const std::wstring &msg, std::exception_ptr e);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Consume and return the <seealso cref="#getCurrentToken current symbol"/>.
|
/// Consume and return the <seealso cref="#getCurrentToken current symbol"/>.
|
||||||
|
@ -294,38 +294,40 @@ namespace runtime {
|
||||||
/// <seealso cref="ParseTreeListener#visitErrorNode"/> is called on any parse
|
/// <seealso cref="ParseTreeListener#visitErrorNode"/> is called on any parse
|
||||||
/// listeners.
|
/// listeners.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual Token::Ref consume();
|
virtual Ref<Token> consume();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Always called by generated parsers upon entry to a rule. Access field
|
/// Always called by generated parsers upon entry to a rule. Access field
|
||||||
/// <seealso cref="#_ctx"/> get the current context.
|
/// <seealso cref="#_ctx"/> get the current context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void enterRule(ParserRuleContext::Ref localctx, int state, int ruleIndex);
|
virtual void enterRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex);
|
||||||
|
|
||||||
virtual void exitRule();
|
virtual void exitRule();
|
||||||
|
|
||||||
virtual void enterOuterAlt(ParserRuleContext::Ref localctx, int altNum);
|
virtual void enterOuterAlt(Ref<ParserRuleContext> localctx, int altNum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the precedence level for the top-most precedence rule.
|
||||||
|
*
|
||||||
|
* @return The precedence level for the top-most precedence rule, or -1 if
|
||||||
|
* the parser context is not nested within a precedence rule.
|
||||||
|
*/
|
||||||
|
int getPrecedence() const;
|
||||||
|
|
||||||
/// @deprecated Use
|
/// @deprecated Use
|
||||||
/// <seealso cref="#enterRecursionRule(ParserRuleContext, int, int, int)"/> instead.
|
/// <seealso cref="#enterRecursionRule(ParserRuleContext, int, int, int)"/> instead.
|
||||||
virtual void enterRecursionRule(ParserRuleContext::Ref localctx, int ruleIndex);
|
virtual void enterRecursionRule(Ref<ParserRuleContext> localctx, int ruleIndex);
|
||||||
virtual void enterRecursionRule(ParserRuleContext::Ref localctx, int state, int ruleIndex, int precedence);
|
virtual void enterRecursionRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex, int precedence);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Like <seealso cref="#enterRule"/> but for recursive rules.
|
|
||||||
/// </summary>
|
|
||||||
virtual void pushNewRecursionContext(ParserRuleContext::Ref localctx, int state, int ruleIndex);
|
|
||||||
|
|
||||||
virtual void unrollRecursionContexts(ParserRuleContext::Ref parentctx);
|
|
||||||
|
|
||||||
virtual ParserRuleContext::Ref getInvokingContext(int ruleIndex);
|
|
||||||
|
|
||||||
virtual ParserRuleContext::Ref getContext();
|
|
||||||
|
|
||||||
virtual void setContext(ParserRuleContext::Ref ctx);
|
|
||||||
|
|
||||||
virtual bool precpred(RuleContext::Ref localctx, int precedence) override;
|
|
||||||
|
|
||||||
|
/** Like {@link #enterRule} but for recursive rules.
|
||||||
|
* Make the current context the child of the incoming localctx.
|
||||||
|
*/
|
||||||
|
virtual void pushNewRecursionContext(Ref<ParserRuleContext> localctx, int state, int ruleIndex);
|
||||||
|
virtual void unrollRecursionContexts(Ref<ParserRuleContext> parentctx);
|
||||||
|
virtual Ref<ParserRuleContext> getInvokingContext(int ruleIndex);
|
||||||
|
virtual Ref<ParserRuleContext> getContext();
|
||||||
|
virtual void setContext(Ref<ParserRuleContext> ctx);
|
||||||
|
virtual bool precpred(Ref<RuleContext> localctx, int precedence) override;
|
||||||
virtual bool inContext(const std::wstring &context);
|
virtual bool inContext(const std::wstring &context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -343,6 +345,8 @@ namespace runtime {
|
||||||
/// the ATN, otherwise {@code false}. </returns>
|
/// the ATN, otherwise {@code false}. </returns>
|
||||||
virtual bool isExpectedToken(int symbol);
|
virtual bool isExpectedToken(int symbol);
|
||||||
|
|
||||||
|
bool isMatchedEOF() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes the set of input symbols which could follow the current parser
|
/// Computes the set of input symbols which could follow the current parser
|
||||||
/// state and context, as given by <seealso cref="#getState"/> and <seealso cref="#getContext"/>,
|
/// state and context, as given by <seealso cref="#getState"/> and <seealso cref="#getContext"/>,
|
||||||
|
@ -357,7 +361,7 @@ namespace runtime {
|
||||||
/// Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found. </summary>
|
/// Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found. </summary>
|
||||||
virtual ssize_t getRuleIndex(const std::wstring &ruleName);
|
virtual ssize_t getRuleIndex(const std::wstring &ruleName);
|
||||||
|
|
||||||
virtual ParserRuleContext::Ref getRuleContext();
|
virtual Ref<ParserRuleContext> getRuleContext();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return List<String> of the rule names in your parser instance
|
/// Return List<String> of the rule names in your parser instance
|
||||||
|
@ -369,7 +373,7 @@ namespace runtime {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual std::vector<std::wstring> getRuleInvocationStack();
|
virtual std::vector<std::wstring> getRuleInvocationStack();
|
||||||
|
|
||||||
virtual std::vector<std::wstring> getRuleInvocationStack(RuleContext::Ref p);
|
virtual std::vector<std::wstring> getRuleInvocationStack(Ref<RuleContext> p);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For debugging and other purposes. </summary>
|
/// For debugging and other purposes. </summary>
|
||||||
|
@ -381,20 +385,35 @@ namespace runtime {
|
||||||
|
|
||||||
virtual std::string getSourceName();
|
virtual std::string getSourceName();
|
||||||
|
|
||||||
|
virtual Ref<atn::ParseInfo> getParseInfo() const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
void setProfile(bool profile);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// During a parse is sometimes useful to listen in on the rule entry and exit
|
/// During a parse is sometimes useful to listen in on the rule entry and exit
|
||||||
/// events as well as token matches. This is for quick and dirty debugging.
|
/// events as well as token matches. This is for quick and dirty debugging.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void setTrace(bool trace);
|
virtual void setTrace(bool trace);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether a {@link TraceListener} is registered as a parse listener
|
||||||
|
* for the parser.
|
||||||
|
*
|
||||||
|
* @see #setTrace(boolean)
|
||||||
|
*/
|
||||||
|
bool isTrace() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// The ParserRuleContext object for the currently executing rule.
|
/// The ParserRuleContext object for the currently executing rule.
|
||||||
/// This is always non-null during the parsing process.
|
/// This is always non-null during the parsing process.
|
||||||
ParserRuleContext::Ref _ctx;
|
Ref<ParserRuleContext> _ctx;
|
||||||
|
|
||||||
/// The error handling strategy for the parser. The default is DefaultErrorStrategy.
|
/// The error handling strategy for the parser. The default is DefaultErrorStrategy.
|
||||||
/// See also getErrorHandler.
|
/// See also getErrorHandler.
|
||||||
std::shared_ptr<ANTLRErrorStrategy> _errHandler;
|
Ref<ANTLRErrorStrategy> _errHandler;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The input stream.
|
/// The input stream.
|
||||||
|
@ -404,6 +423,7 @@ namespace runtime {
|
||||||
TokenStream *_input;
|
TokenStream *_input;
|
||||||
|
|
||||||
std::vector<int> _precedenceStack;
|
std::vector<int> _precedenceStack;
|
||||||
|
|
||||||
//Mutex to manage synchronized access for multithreading in the parser
|
//Mutex to manage synchronized access for multithreading in the parser
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
|
|
||||||
|
@ -420,7 +440,7 @@ namespace runtime {
|
||||||
/// events during the parse.
|
/// events during the parse.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref= #addParseListener </seealso>
|
/// <seealso cref= #addParseListener </seealso>
|
||||||
std::vector<std::shared_ptr<tree::ParseTreeListener>> _parseListeners;
|
std::vector<Ref<tree::ParseTreeListener>> _parseListeners;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of syntax errors reported during parsing. This value is
|
/// The number of syntax errors reported during parsing. This value is
|
||||||
|
@ -428,6 +448,9 @@ namespace runtime {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int _syntaxErrors;
|
int _syntaxErrors;
|
||||||
|
|
||||||
|
/** Indicates parser has match()ed EOF token. See {@link #exitRule()}. */
|
||||||
|
bool _matchedEOF;
|
||||||
|
|
||||||
virtual void addContextToParseTree();
|
virtual void addContextToParseTree();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -442,7 +465,7 @@ namespace runtime {
|
||||||
/// later call to setTrace(false). The listener itself is
|
/// later call to setTrace(false). The listener itself is
|
||||||
/// implemented as a parser listener so this field is not directly used by
|
/// implemented as a parser listener so this field is not directly used by
|
||||||
/// other parser methods.
|
/// other parser methods.
|
||||||
std::shared_ptr<TraceListener> _tracer;
|
Ref<TraceListener> _tracer;
|
||||||
|
|
||||||
void InitializeInstanceFields();
|
void InitializeInstanceFields();
|
||||||
};
|
};
|
||||||
|
|
|
@ -105,10 +105,10 @@ std::wstring ParserInterpreter::getGrammarFileName() const {
|
||||||
return _grammarFileName;
|
return _grammarFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserRuleContext::Ref ParserInterpreter::parse(int startRuleIndex) {
|
Ref<ParserRuleContext> ParserInterpreter::parse(int startRuleIndex) {
|
||||||
atn::RuleStartState *startRuleStartState = _atn.ruleToStartState[(size_t)startRuleIndex];
|
atn::RuleStartState *startRuleStartState = _atn.ruleToStartState[(size_t)startRuleIndex];
|
||||||
|
|
||||||
std::shared_ptr<InterpreterRuleContext> rootContext =
|
Ref<InterpreterRuleContext> rootContext =
|
||||||
std::make_shared<InterpreterRuleContext>(std::weak_ptr<ParserRuleContext>(), atn::ATNState::INVALID_STATE_NUMBER, startRuleIndex);
|
std::make_shared<InterpreterRuleContext>(std::weak_ptr<ParserRuleContext>(), atn::ATNState::INVALID_STATE_NUMBER, startRuleIndex);
|
||||||
|
|
||||||
if (startRuleStartState->isLeftRecursiveRule) {
|
if (startRuleStartState->isLeftRecursiveRule) {
|
||||||
|
@ -137,7 +137,7 @@ ParserRuleContext::Ref ParserInterpreter::parse(int startRuleIndex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserInterpreter::enterRecursionRule(ParserRuleContext::Ref localctx, int state, int ruleIndex, int precedence) {
|
void ParserInterpreter::enterRecursionRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex, int precedence) {
|
||||||
_parentContextStack.push({ _ctx, localctx->invokingState });
|
_parentContextStack.push({ _ctx, localctx->invokingState });
|
||||||
Parser::enterRecursionRule(localctx, state, ruleIndex, precedence);
|
Parser::enterRecursionRule(localctx, state, ruleIndex, precedence);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
||||||
switch (transition->getSerializationType()) {
|
switch (transition->getSerializationType()) {
|
||||||
case atn::Transition::EPSILON:
|
case atn::Transition::EPSILON:
|
||||||
if (_pushRecursionContextStates[(size_t)p->stateNumber] == 1 && is<atn::LoopEndState*>(transition->target)) {
|
if (_pushRecursionContextStates[(size_t)p->stateNumber] == 1 && is<atn::LoopEndState*>(transition->target)) {
|
||||||
std::shared_ptr<InterpreterRuleContext> ruleContext = std::make_shared<InterpreterRuleContext>(_parentContextStack.top().first,
|
Ref<InterpreterRuleContext> ruleContext = std::make_shared<InterpreterRuleContext>(_parentContextStack.top().first,
|
||||||
_parentContextStack.top().second, _ctx->getRuleIndex());
|
_parentContextStack.top().second, _ctx->getRuleIndex());
|
||||||
pushNewRecursionContext(ruleContext, _atn.ruleToStartState[(size_t)p->ruleIndex]->stateNumber,
|
pushNewRecursionContext(ruleContext, _atn.ruleToStartState[(size_t)p->ruleIndex]->stateNumber,
|
||||||
(int)ruleContext->getRuleIndex());
|
(int)ruleContext->getRuleIndex());
|
||||||
|
@ -186,7 +186,7 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
||||||
{
|
{
|
||||||
atn::RuleStartState *ruleStartState = (atn::RuleStartState*)(transition->target);
|
atn::RuleStartState *ruleStartState = (atn::RuleStartState*)(transition->target);
|
||||||
int ruleIndex = ruleStartState->ruleIndex;
|
int ruleIndex = ruleStartState->ruleIndex;
|
||||||
std::shared_ptr<InterpreterRuleContext> ruleContext = std::make_shared<InterpreterRuleContext>(_ctx, p->stateNumber, ruleIndex);
|
Ref<InterpreterRuleContext> ruleContext = std::make_shared<InterpreterRuleContext>(_ctx, p->stateNumber, ruleIndex);
|
||||||
if (ruleStartState->isLeftRecursiveRule) {
|
if (ruleStartState->isLeftRecursiveRule) {
|
||||||
enterRecursionRule(ruleContext, ruleStartState->stateNumber, ruleIndex, ((atn::RuleTransition*)(transition))->precedence);
|
enterRecursionRule(ruleContext, ruleStartState->stateNumber, ruleIndex, ((atn::RuleTransition*)(transition))->precedence);
|
||||||
} else {
|
} else {
|
||||||
|
@ -229,7 +229,7 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
||||||
void ParserInterpreter::visitRuleStopState(atn::ATNState *p) {
|
void ParserInterpreter::visitRuleStopState(atn::ATNState *p) {
|
||||||
atn::RuleStartState *ruleStartState = _atn.ruleToStartState[(size_t)p->ruleIndex];
|
atn::RuleStartState *ruleStartState = _atn.ruleToStartState[(size_t)p->ruleIndex];
|
||||||
if (ruleStartState->isLeftRecursiveRule) {
|
if (ruleStartState->isLeftRecursiveRule) {
|
||||||
std::pair<ParserRuleContext::Ref, int> parentContext = _parentContextStack.top();
|
std::pair<Ref<ParserRuleContext>, int> parentContext = _parentContextStack.top();
|
||||||
_parentContextStack.pop();
|
_parentContextStack.pop();
|
||||||
|
|
||||||
unrollRecursionContexts(parentContext.first);
|
unrollRecursionContexts(parentContext.first);
|
||||||
|
|
|
@ -67,9 +67,9 @@ namespace runtime {
|
||||||
virtual std::wstring getGrammarFileName() const override;
|
virtual std::wstring getGrammarFileName() const override;
|
||||||
|
|
||||||
/// Begin parsing at startRuleIndex
|
/// Begin parsing at startRuleIndex
|
||||||
virtual ParserRuleContext::Ref parse(int startRuleIndex);
|
virtual Ref<ParserRuleContext> parse(int startRuleIndex);
|
||||||
|
|
||||||
virtual void enterRecursionRule(ParserRuleContext::Ref localctx, int state, int ruleIndex, int precedence) override;
|
virtual void enterRecursionRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex, int precedence) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::wstring _grammarFileName;
|
const std::wstring _grammarFileName;
|
||||||
|
@ -80,9 +80,9 @@ namespace runtime {
|
||||||
antlrcpp::BitSet _pushRecursionContextStates;
|
antlrcpp::BitSet _pushRecursionContextStates;
|
||||||
|
|
||||||
std::vector<dfa::DFA> _decisionToDFA; // not shared like it is for generated parsers
|
std::vector<dfa::DFA> _decisionToDFA; // not shared like it is for generated parsers
|
||||||
std::shared_ptr<atn::PredictionContextCache> _sharedContextCache;
|
Ref<atn::PredictionContextCache> _sharedContextCache;
|
||||||
|
|
||||||
std::stack<std::pair<ParserRuleContext::Ref, int>> _parentContextStack;
|
std::stack<std::pair<Ref<ParserRuleContext>, int>> _parentContextStack;
|
||||||
|
|
||||||
virtual atn::ATNState *getATNState();
|
virtual atn::ATNState *getATNState();
|
||||||
virtual void visitState(atn::ATNState *p);
|
virtual void visitState(atn::ATNState *p);
|
||||||
|
|
|
@ -43,7 +43,7 @@ using namespace antlrcpp;
|
||||||
ParserRuleContext::ParserRuleContext() {
|
ParserRuleContext::ParserRuleContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserRuleContext::copyFrom(std::shared_ptr<ParserRuleContext> ctx) {
|
void ParserRuleContext::copyFrom(Ref<ParserRuleContext> ctx) {
|
||||||
// from RuleContext
|
// from RuleContext
|
||||||
this->parent = ctx->parent;
|
this->parent = ctx->parent;
|
||||||
this->invokingState = ctx->invokingState;
|
this->invokingState = ctx->invokingState;
|
||||||
|
@ -56,18 +56,18 @@ ParserRuleContext::ParserRuleContext(std::weak_ptr<ParserRuleContext> parent, in
|
||||||
: RuleContext(parent, invokingStateNumber) {
|
: RuleContext(parent, invokingStateNumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserRuleContext::enterRule(std::shared_ptr<tree::ParseTreeListener> listener) {
|
void ParserRuleContext::enterRule(Ref<tree::ParseTreeListener> listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserRuleContext::exitRule(std::shared_ptr<tree::ParseTreeListener> listener) {
|
void ParserRuleContext::exitRule(Ref<tree::ParseTreeListener> listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<tree::TerminalNode> ParserRuleContext::addChild(std::shared_ptr<tree::TerminalNode> t) {
|
Ref<tree::TerminalNode> ParserRuleContext::addChild(Ref<tree::TerminalNode> t) {
|
||||||
children.push_back(t);
|
children.push_back(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleContext::Ref ParserRuleContext::addChild(RuleContext::Ref ruleInvocation) {
|
Ref<RuleContext> ParserRuleContext::addChild(Ref<RuleContext> ruleInvocation) {
|
||||||
children.push_back(ruleInvocation);
|
children.push_back(ruleInvocation);
|
||||||
return ruleInvocation;
|
return ruleInvocation;
|
||||||
}
|
}
|
||||||
|
@ -78,25 +78,25 @@ void ParserRuleContext::removeLastChild() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<tree::TerminalNode> ParserRuleContext::addChild(Token::Ref matchedToken) {
|
Ref<tree::TerminalNode> ParserRuleContext::addChild(Ref<Token> matchedToken) {
|
||||||
std::shared_ptr<tree::TerminalNodeImpl> t = std::make_shared<tree::TerminalNodeImpl>(matchedToken);
|
Ref<tree::TerminalNodeImpl> t = std::make_shared<tree::TerminalNodeImpl>(matchedToken);
|
||||||
addChild(t);
|
addChild(t);
|
||||||
t->parent = shared_from_this();
|
t->parent = shared_from_this();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<tree::ErrorNode> ParserRuleContext::addErrorNode(Token::Ref badToken) {
|
Ref<tree::ErrorNode> ParserRuleContext::addErrorNode(Ref<Token> badToken) {
|
||||||
std::shared_ptr<tree::ErrorNodeImpl> t = std::make_shared<tree::ErrorNodeImpl>(badToken);
|
Ref<tree::ErrorNodeImpl> t = std::make_shared<tree::ErrorNodeImpl>(badToken);
|
||||||
addChild(t);
|
addChild(t);
|
||||||
t->parent = shared_from_this();
|
t->parent = shared_from_this();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<tree::Tree> ParserRuleContext::getChildReference(std::size_t i) {
|
Ref<tree::Tree> ParserRuleContext::getChildReference(std::size_t i) {
|
||||||
return children[i];
|
return children[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<tree::TerminalNode> ParserRuleContext::getToken(int ttype, std::size_t i) {
|
Ref<tree::TerminalNode> ParserRuleContext::getToken(int ttype, std::size_t i) {
|
||||||
if (i >= children.size()) {
|
if (i >= children.size()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ std::shared_ptr<tree::TerminalNode> ParserRuleContext::getToken(int ttype, std::
|
||||||
size_t j = 0; // what token with ttype have we found?
|
size_t j = 0; // what token with ttype have we found?
|
||||||
for (auto o : children) {
|
for (auto o : children) {
|
||||||
if (is<tree::TerminalNode>(o)) {
|
if (is<tree::TerminalNode>(o)) {
|
||||||
std::shared_ptr<tree::TerminalNode> tnode = std::dynamic_pointer_cast<tree::TerminalNode>(o);
|
Ref<tree::TerminalNode> tnode = std::dynamic_pointer_cast<tree::TerminalNode>(o);
|
||||||
Token::Ref symbol = tnode->getSymbol();
|
Ref<Token> symbol = tnode->getSymbol();
|
||||||
if (symbol->getType() == ttype) {
|
if (symbol->getType() == ttype) {
|
||||||
if (j++ == i) {
|
if (j++ == i) {
|
||||||
return tnode;
|
return tnode;
|
||||||
|
@ -117,12 +117,12 @@ std::shared_ptr<tree::TerminalNode> ParserRuleContext::getToken(int ttype, std::
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<tree::TerminalNode>> ParserRuleContext::getTokens(int ttype) {
|
std::vector<Ref<tree::TerminalNode>> ParserRuleContext::getTokens(int ttype) {
|
||||||
std::vector<std::shared_ptr<tree::TerminalNode>> tokens;
|
std::vector<Ref<tree::TerminalNode>> tokens;
|
||||||
for (auto &o : children) {
|
for (auto &o : children) {
|
||||||
if (is<tree::TerminalNode>(o)) {
|
if (is<tree::TerminalNode>(o)) {
|
||||||
std::shared_ptr<tree::TerminalNode> tnode = std::dynamic_pointer_cast<tree::TerminalNode>(o);
|
Ref<tree::TerminalNode> tnode = std::dynamic_pointer_cast<tree::TerminalNode>(o);
|
||||||
Token::Ref symbol = tnode->getSymbol();
|
Ref<Token> symbol = tnode->getSymbol();
|
||||||
if (symbol->getType() == ttype) {
|
if (symbol->getType() == ttype) {
|
||||||
tokens.push_back(tnode);
|
tokens.push_back(tnode);
|
||||||
}
|
}
|
||||||
|
@ -132,24 +132,26 @@ std::vector<std::shared_ptr<tree::TerminalNode>> ParserRuleContext::getTokens(in
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::size_t ParserRuleContext::getChildCount() {
|
std::size_t ParserRuleContext::getChildCount() {
|
||||||
return children.size();
|
return children.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
misc::Interval ParserRuleContext::getSourceInterval() {
|
misc::Interval ParserRuleContext::getSourceInterval() {
|
||||||
if (start == nullptr || stop == nullptr) {
|
if (start == nullptr) {
|
||||||
return misc::Interval::INVALID;
|
return misc::Interval::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stop == nullptr || stop->getTokenIndex() < start->getTokenIndex()) {
|
||||||
|
return misc::Interval(start->getTokenIndex(), start->getTokenIndex() - 1); // empty
|
||||||
|
}
|
||||||
return misc::Interval(start->getTokenIndex(), stop->getTokenIndex());
|
return misc::Interval(start->getTokenIndex(), stop->getTokenIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref ParserRuleContext::getStart() {
|
Ref<Token> ParserRuleContext::getStart() {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref ParserRuleContext::getStop() {
|
Ref<Token> ParserRuleContext::getStop() {
|
||||||
return stop;
|
return stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Token.h"
|
|
||||||
#include "RuleContext.h"
|
#include "RuleContext.h"
|
||||||
#include "CPPUtils.h"
|
#include "CPPUtils.h"
|
||||||
|
|
||||||
|
@ -45,9 +44,8 @@ namespace runtime {
|
||||||
///
|
///
|
||||||
/// Contains all of the information about the current rule not stored in the
|
/// Contains all of the information about the current rule not stored in the
|
||||||
/// RuleContext. It handles parse tree children list, Any ATN state
|
/// RuleContext. It handles parse tree children list, Any ATN state
|
||||||
/// tracing, and the default values available for rule indications:
|
/// tracing, and the default values available for rule invocatons:
|
||||||
/// start, stop, rule index, current alt number, current
|
/// start, stop, rule index, current alt number.
|
||||||
/// ATN state.
|
|
||||||
///
|
///
|
||||||
/// Subclasses made for each rule and grammar track the parameters,
|
/// Subclasses made for each rule and grammar track the parameters,
|
||||||
/// return values, locals, and labels specific to that rule. These
|
/// return values, locals, and labels specific to that rule. These
|
||||||
|
@ -66,14 +64,12 @@ namespace runtime {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ParserRuleContext : public RuleContext {
|
class ParserRuleContext : public RuleContext {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<ParserRuleContext> Ref;
|
|
||||||
|
|
||||||
/// If we are debugging or building a parse tree for a visitor,
|
/// If we are debugging or building a parse tree for a visitor,
|
||||||
/// we need to track all of the tokens and rule invocations associated
|
/// we need to track all of the tokens and rule invocations associated
|
||||||
/// with this rule's context. This is empty for parsing w/o tree constr.
|
/// with this rule's context. This is empty for parsing w/o tree constr.
|
||||||
/// operation because we don't the need to track the details about
|
/// operation because we don't the need to track the details about
|
||||||
/// how we parse this rule.
|
/// how we parse this rule.
|
||||||
std::vector<std::shared_ptr<ParseTree>> children;
|
std::vector<Ref<ParseTree>> children;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For debugging/tracing purposes, we want to track all of the nodes in
|
/// For debugging/tracing purposes, we want to track all of the nodes in
|
||||||
|
@ -96,7 +92,7 @@ namespace runtime {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// public List<Integer> states;
|
// public List<Integer> states;
|
||||||
|
|
||||||
Token::Ref start, stop;
|
Ref<Token> start, stop;
|
||||||
|
|
||||||
/// The exception that forced this rule to return. If the rule successfully
|
/// The exception that forced this rule to return. If the rule successfully
|
||||||
/// completed, this is "null exception pointer".
|
/// completed, this is "null exception pointer".
|
||||||
|
@ -105,38 +101,39 @@ namespace runtime {
|
||||||
ParserRuleContext();
|
ParserRuleContext();
|
||||||
virtual ~ParserRuleContext() {}
|
virtual ~ParserRuleContext() {}
|
||||||
|
|
||||||
/// <summary>
|
/** COPY a ctx (I'm deliberately not using copy constructor) to avoid
|
||||||
/// COPY a ctx (I'm deliberately not copy constructor) </summary>
|
* confusion with creating node with parent. Does not copy children.
|
||||||
virtual void copyFrom(std::shared_ptr<ParserRuleContext> ctx);
|
*/
|
||||||
|
virtual void copyFrom(Ref<ParserRuleContext> ctx);
|
||||||
|
|
||||||
ParserRuleContext(std::weak_ptr<ParserRuleContext> parent, int invokingStateNumber);
|
ParserRuleContext(std::weak_ptr<ParserRuleContext> parent, int invokingStateNumber);
|
||||||
|
|
||||||
// Double dispatch methods for listeners
|
// Double dispatch methods for listeners
|
||||||
|
|
||||||
virtual void enterRule(std::shared_ptr<tree::ParseTreeListener> listener);
|
virtual void enterRule(Ref<tree::ParseTreeListener> listener);
|
||||||
virtual void exitRule(std::shared_ptr<tree::ParseTreeListener> listener);
|
virtual void exitRule(Ref<tree::ParseTreeListener> listener);
|
||||||
|
|
||||||
/// Does not set parent link; other add methods do that.
|
/// Does not set parent link; other add methods do that.
|
||||||
virtual std::shared_ptr<tree::TerminalNode> addChild(std::shared_ptr<tree::TerminalNode> t);
|
virtual Ref<tree::TerminalNode> addChild(Ref<tree::TerminalNode> t);
|
||||||
virtual RuleContext::Ref addChild(RuleContext::Ref ruleInvocation);
|
virtual Ref<RuleContext> addChild(Ref<RuleContext> ruleInvocation);
|
||||||
|
|
||||||
/// Used by enterOuterAlt to toss out a RuleContext previously added as
|
/// Used by enterOuterAlt to toss out a RuleContext previously added as
|
||||||
/// we entered a rule. If we have # label, we will need to remove
|
/// we entered a rule. If we have # label, we will need to remove
|
||||||
/// generic ruleContext object.
|
/// generic ruleContext object.
|
||||||
virtual void removeLastChild();
|
virtual void removeLastChild();
|
||||||
|
|
||||||
virtual std::shared_ptr<tree::TerminalNode> addChild(Token::Ref matchedToken);
|
virtual Ref<tree::TerminalNode> addChild(Ref<Token> matchedToken);
|
||||||
|
|
||||||
virtual std::shared_ptr<tree::ErrorNode> addErrorNode(Token::Ref badToken);
|
virtual Ref<tree::ErrorNode> addErrorNode(Ref<Token> badToken);
|
||||||
|
|
||||||
std::weak_ptr<ParserRuleContext> getParent() { return std::dynamic_pointer_cast<ParserRuleContext>(getParentReference().lock()); };
|
std::weak_ptr<ParserRuleContext> getParent() { return std::dynamic_pointer_cast<ParserRuleContext>(getParentReference().lock()); };
|
||||||
|
|
||||||
virtual std::shared_ptr<tree::TerminalNode> getToken(int ttype, std::size_t i);
|
virtual Ref<tree::TerminalNode> getToken(int ttype, std::size_t i);
|
||||||
|
|
||||||
virtual std::vector<std::shared_ptr<tree::TerminalNode>> getTokens(int ttype);
|
virtual std::vector<Ref<tree::TerminalNode>> getTokens(int ttype);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::shared_ptr<T> getRuleContext(size_t i) {
|
Ref<T> getRuleContext(size_t i) {
|
||||||
if (children.empty()) {
|
if (children.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +150,8 @@ namespace runtime {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::vector<std::shared_ptr<T>> getRuleContexts() {
|
std::vector<Ref<T>> getRuleContexts() {
|
||||||
std::vector<std::shared_ptr<T>> contexts;
|
std::vector<Ref<T>> contexts;
|
||||||
for (auto &child : children) {
|
for (auto &child : children) {
|
||||||
if (antlrcpp::is<T>(child)) {
|
if (antlrcpp::is<T>(child)) {
|
||||||
contexts.push_back(std::dynamic_pointer_cast<T>(child));
|
contexts.push_back(std::dynamic_pointer_cast<T>(child));
|
||||||
|
@ -167,15 +164,26 @@ namespace runtime {
|
||||||
virtual std::size_t getChildCount() override;
|
virtual std::size_t getChildCount() override;
|
||||||
virtual misc::Interval getSourceInterval() override;
|
virtual misc::Interval getSourceInterval() override;
|
||||||
|
|
||||||
virtual Token::Ref getStart();
|
/**
|
||||||
virtual Token::Ref getStop();
|
* Get the initial token in this context.
|
||||||
|
* Note that the range from start to stop is inclusive, so for rules that do not consume anything
|
||||||
|
* (for example, zero length or error productions) this token may exceed stop.
|
||||||
|
*/
|
||||||
|
virtual Ref<Token> getStart();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the final token in this context.
|
||||||
|
* Note that the range from start to stop is inclusive, so for rules that do not consume anything
|
||||||
|
* (for example, zero length or error productions) this token may precede start.
|
||||||
|
*/
|
||||||
|
virtual Ref<Token> getStop();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used for rule context info debugging during parse-time, not so much for ATN debugging </summary>
|
/// Used for rule context info debugging during parse-time, not so much for ATN debugging </summary>
|
||||||
virtual std::wstring toInfoString(Parser *recognizer);
|
virtual std::wstring toInfoString(Parser *recognizer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::shared_ptr<Tree> getChildReference(size_t i) override;
|
virtual Ref<Tree> getChildReference(size_t i) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -49,7 +49,7 @@ void ProxyErrorListener::removeErrorListeners() {
|
||||||
_delegates.clear();
|
_delegates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyErrorListener::syntaxError(IRecognizer *recognizer, Token::Ref offendingSymbol, size_t line,
|
void ProxyErrorListener::syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, size_t line,
|
||||||
int charPositionInLine, const std::wstring &msg, std::exception_ptr e) {
|
int charPositionInLine, const std::wstring &msg, std::exception_ptr e) {
|
||||||
|
|
||||||
for (auto listener : _delegates) {
|
for (auto listener : _delegates) {
|
||||||
|
@ -58,21 +58,21 @@ void ProxyErrorListener::syntaxError(IRecognizer *recognizer, Token::Ref offendi
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
void ProxyErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
bool exact, const antlrcpp::BitSet &ambigAlts, std::shared_ptr<atn::ATNConfigSet> configs) {
|
bool exact, const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) {
|
||||||
for (auto listener : _delegates) {
|
for (auto listener : _delegates) {
|
||||||
listener->reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
|
listener->reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
void ProxyErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
|
||||||
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, std::shared_ptr<atn::ATNConfigSet> configs) {
|
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) {
|
||||||
for (auto listener : _delegates) {
|
for (auto listener : _delegates) {
|
||||||
listener->reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
|
listener->reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
void ProxyErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
int prediction, std::shared_ptr<atn::ATNConfigSet> configs) {
|
int prediction, Ref<atn::ATNConfigSet> configs) {
|
||||||
for (auto listener : _delegates) {
|
for (auto listener : _delegates) {
|
||||||
listener->reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
|
listener->reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,17 +51,17 @@ namespace runtime {
|
||||||
void removeErrorListener(ANTLRErrorListener *listener);
|
void removeErrorListener(ANTLRErrorListener *listener);
|
||||||
void removeErrorListeners();
|
void removeErrorListeners();
|
||||||
|
|
||||||
void syntaxError(IRecognizer *recognizer, Token::Ref offendingSymbol, size_t line, int charPositionInLine,
|
void syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, size_t line, int charPositionInLine,
|
||||||
const std::wstring &msg, std::exception_ptr e) override;
|
const std::wstring &msg, std::exception_ptr e) override;
|
||||||
|
|
||||||
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
|
||||||
const antlrcpp::BitSet &ambigAlts, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) override;
|
||||||
|
|
||||||
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
const antlrcpp::BitSet &conflictingAlts, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) override;
|
||||||
|
|
||||||
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
|
||||||
int prediction, std::shared_ptr<atn::ATNConfigSet> configs) override;
|
int prediction, Ref<atn::ATNConfigSet> configs) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -33,18 +33,19 @@
|
||||||
#include "Recognizer.h"
|
#include "Recognizer.h"
|
||||||
#include "Strings.h"
|
#include "Strings.h"
|
||||||
#include "ParserRuleContext.h"
|
#include "ParserRuleContext.h"
|
||||||
|
#include "IntervalSet.h"
|
||||||
|
|
||||||
#include "RecognitionException.h"
|
#include "RecognitionException.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
RecognitionException::RecognitionException(IRecognizer *recognizer, IntStream *input,
|
RecognitionException::RecognitionException(IRecognizer *recognizer, IntStream *input,
|
||||||
ParserRuleContext::Ref ctx, Token::Ref offendingToken)
|
Ref<ParserRuleContext> ctx, Ref<Token> offendingToken)
|
||||||
: RecognitionException("", recognizer, input, ctx, offendingToken) {
|
: RecognitionException("", recognizer, input, ctx, offendingToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RecognitionException::RecognitionException(const std::string &message, IRecognizer *recognizer, IntStream *input,
|
RecognitionException::RecognitionException(const std::string &message, IRecognizer *recognizer, IntStream *input,
|
||||||
ParserRuleContext::Ref ctx, Token::Ref offendingToken)
|
Ref<ParserRuleContext> ctx, Ref<Token> offendingToken)
|
||||||
: RuntimeException(message), _recognizer(recognizer), _input(input), _offendingToken(offendingToken), _ctx(ctx) {
|
: RuntimeException(message), _recognizer(recognizer), _input(input), _offendingToken(offendingToken), _ctx(ctx) {
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
if (recognizer != nullptr) {
|
if (recognizer != nullptr) {
|
||||||
|
@ -67,7 +68,7 @@ misc::IntervalSet RecognitionException::getExpectedTokens() const {
|
||||||
return misc::IntervalSet::EMPTY_SET;
|
return misc::IntervalSet::EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleContext::Ref RecognitionException::getCtx() const {
|
Ref<RuleContext> RecognitionException::getCtx() const {
|
||||||
return _ctx;
|
return _ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ IntStream* RecognitionException::getInputStream() const {
|
||||||
return _input;
|
return _input;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref RecognitionException::getOffendingToken() const {
|
Ref<Token> RecognitionException::getOffendingToken() const {
|
||||||
return _offendingToken;
|
return _offendingToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Exceptions.h"
|
#include "Exceptions.h"
|
||||||
#include "IntervalSet.h"
|
|
||||||
#include "IRecognizer.h"
|
|
||||||
#include "IntStream.h"
|
|
||||||
#include "RuleContext.h"
|
|
||||||
#include "ParserRuleContext.h"
|
|
||||||
#include "Token.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -54,20 +48,20 @@ namespace runtime {
|
||||||
/// The Recognizer where this exception originated.
|
/// The Recognizer where this exception originated.
|
||||||
IRecognizer *_recognizer;
|
IRecognizer *_recognizer;
|
||||||
IntStream *_input;
|
IntStream *_input;
|
||||||
ParserRuleContext::Ref _ctx;
|
Ref<ParserRuleContext> _ctx;
|
||||||
|
|
||||||
/// The current Token when an error occurred. Since not all streams
|
/// The current Token when an error occurred. Since not all streams
|
||||||
/// support accessing symbols by index, we have to track the Token
|
/// support accessing symbols by index, we have to track the Token
|
||||||
/// instance itself.
|
/// instance itself.
|
||||||
Token::Ref _offendingToken;
|
Ref<Token> _offendingToken;
|
||||||
|
|
||||||
int _offendingState;
|
int _offendingState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RecognitionException(IRecognizer *recognizer, IntStream *input, ParserRuleContext::Ref ctx,
|
RecognitionException(IRecognizer *recognizer, IntStream *input, Ref<ParserRuleContext> ctx,
|
||||||
Token::Ref offendingToken = Token::Ref());
|
Ref<Token> offendingToken = Ref<Token>());
|
||||||
RecognitionException(const std::string &message, IRecognizer *recognizer, IntStream *input,
|
RecognitionException(const std::string &message, IRecognizer *recognizer, IntStream *input,
|
||||||
ParserRuleContext::Ref ctx, Token::Ref offendingToken = Token::Ref());
|
Ref<ParserRuleContext> ctx, Ref<Token> offendingToken = Ref<Token>());
|
||||||
|
|
||||||
/// Get the ATN state number the parser was in at the time the error
|
/// Get the ATN state number the parser was in at the time the error
|
||||||
/// occurred. For NoViableAltException and
|
/// occurred. For NoViableAltException and
|
||||||
|
@ -99,7 +93,7 @@ namespace runtime {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns> The <seealso cref="RuleContext"/> at the time this exception was thrown.
|
/// <returns> The <seealso cref="RuleContext"/> at the time this exception was thrown.
|
||||||
/// If the context is not available, this method returns {@code null}. </returns>
|
/// If the context is not available, this method returns {@code null}. </returns>
|
||||||
virtual RuleContext::Ref getCtx() const;
|
virtual Ref<RuleContext> getCtx() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the input stream which is the symbol source for the recognizer where
|
/// Gets the input stream which is the symbol source for the recognizer where
|
||||||
|
@ -112,7 +106,7 @@ namespace runtime {
|
||||||
/// available. </returns>
|
/// available. </returns>
|
||||||
virtual IntStream* getInputStream() const;
|
virtual IntStream* getInputStream() const;
|
||||||
|
|
||||||
virtual Token::Ref getOffendingToken() const;
|
virtual Ref<Token> getOffendingToken() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <seealso cref="Recognizer"/> where this exception occurred.
|
/// Gets the <seealso cref="Recognizer"/> where this exception occurred.
|
||||||
|
|
|
@ -34,13 +34,18 @@
|
||||||
#include "CPPUtils.h"
|
#include "CPPUtils.h"
|
||||||
#include "Strings.h"
|
#include "Strings.h"
|
||||||
#include "Token.h"
|
#include "Token.h"
|
||||||
|
#include "ATN.h"
|
||||||
|
#include "ATNSimulator.h"
|
||||||
#include "CPPUtils.h"
|
#include "CPPUtils.h"
|
||||||
|
|
||||||
|
#include "Vocabulary.h"
|
||||||
|
#include "VocabularyImpl.h"
|
||||||
|
|
||||||
#include "Recognizer.h"
|
#include "Recognizer.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
std::map<std::vector<std::wstring>, std::map<std::wstring, size_t>> Recognizer::_tokenTypeMapCache;
|
std::map<Ref<dfa::Vocabulary>, std::map<std::wstring, size_t>> Recognizer::_tokenTypeMapCache;
|
||||||
std::map<std::vector<std::wstring>, std::map<std::wstring, size_t>> Recognizer::_ruleIndexMapCache;
|
std::map<std::vector<std::wstring>, std::map<std::wstring, size_t>> Recognizer::_ruleIndexMapCache;
|
||||||
|
|
||||||
Recognizer::Recognizer() {
|
Recognizer::Recognizer() {
|
||||||
|
@ -48,21 +53,32 @@ Recognizer::Recognizer() {
|
||||||
_proxListener.addErrorListener(&ConsoleErrorListener::INSTANCE);
|
_proxListener.addErrorListener(&ConsoleErrorListener::INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::wstring, size_t> Recognizer::getTokenTypeMap() {
|
Ref<dfa::Vocabulary> Recognizer::getVocabulary() const {
|
||||||
const std::vector<std::wstring>& tokenNames = getTokenNames();
|
return dfa::VocabularyImpl::fromTokenNames(getTokenNames());
|
||||||
if (tokenNames.empty()) {
|
|
||||||
throw L"The current recognizer does not provide a list of token names.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::wstring, size_t> Recognizer::getTokenTypeMap() {
|
||||||
|
Ref<dfa::Vocabulary> vocabulary = getVocabulary();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lck(mtx);
|
std::lock_guard<std::mutex> lck(mtx);
|
||||||
std::map<std::wstring, size_t> result;
|
std::map<std::wstring, size_t> result;
|
||||||
auto iterator = _tokenTypeMapCache.find(tokenNames);
|
auto iterator = _tokenTypeMapCache.find(vocabulary);
|
||||||
if (iterator != _tokenTypeMapCache.end()) {
|
if (iterator != _tokenTypeMapCache.end()) {
|
||||||
result = iterator->second;
|
result = iterator->second;
|
||||||
} else {
|
} else {
|
||||||
result = antlrcpp::toMap(tokenNames);
|
for (size_t i = 0; i < getATN().maxTokenType; ++i) {
|
||||||
|
std::wstring literalName = vocabulary->getLiteralName(i);
|
||||||
|
if (!literalName.empty()) {
|
||||||
|
result[literalName] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring symbolicName = vocabulary->getSymbolicName(i);
|
||||||
|
if (!symbolicName.empty()) {
|
||||||
|
result[symbolicName] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
result[L"EOF"] = EOF;
|
result[L"EOF"] = EOF;
|
||||||
_tokenTypeMapCache[tokenNames] = result;
|
_tokenTypeMapCache[vocabulary] = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -95,6 +111,17 @@ size_t Recognizer::getTokenType(const std::wstring &tokenName) {
|
||||||
return iterator->second;
|
return iterator->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<atn::ParseInfo> Recognizer::getParseInfo() const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recognizer::setInterpreter(atn::ATNSimulator *interpreter) {
|
||||||
|
// Usually the interpreter is set by the descendant (lexer or parser (simulator), but can also be exchanged
|
||||||
|
// by the profiling ATN simulator.
|
||||||
|
delete _interpreter;
|
||||||
|
_interpreter = interpreter;
|
||||||
|
}
|
||||||
|
|
||||||
std::wstring Recognizer::getErrorHeader(RecognitionException *e) {
|
std::wstring Recognizer::getErrorHeader(RecognitionException *e) {
|
||||||
// We're having issues with cross header dependencies, these two classes will need to be
|
// We're having issues with cross header dependencies, these two classes will need to be
|
||||||
// rewritten to remove that.
|
// rewritten to remove that.
|
||||||
|
@ -106,7 +133,7 @@ std::wstring Recognizer::getErrorHeader(RecognitionException *e) {
|
||||||
|
|
||||||
std::wstring Recognizer::getTokenErrorDisplay(Token *t) {
|
std::wstring Recognizer::getTokenErrorDisplay(Token *t) {
|
||||||
if (t == nullptr) {
|
if (t == nullptr) {
|
||||||
return L"<no token>";
|
return L"<no Token>";
|
||||||
}
|
}
|
||||||
std::wstring s = t->getText();
|
std::wstring s = t->getText();
|
||||||
if (s == L"") {
|
if (s == L"") {
|
||||||
|
@ -140,15 +167,15 @@ ProxyErrorListener& Recognizer::getErrorListenerDispatch() {
|
||||||
return _proxListener;
|
return _proxListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Recognizer::sempred(RuleContext::Ref localctx, int ruleIndex, int actionIndex) {
|
bool Recognizer::sempred(Ref<RuleContext> localctx, int ruleIndex, int actionIndex) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Recognizer::precpred(RuleContext::Ref localctx, int precedence) {
|
bool Recognizer::precpred(Ref<RuleContext> localctx, int precedence) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Recognizer::action(RuleContext::Ref localctx, int ruleIndex, int actionIndex) {
|
void Recognizer::action(Ref<RuleContext> localctx, int ruleIndex, int actionIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Recognizer::getState() {
|
int Recognizer::getState() {
|
||||||
|
|
|
@ -43,31 +43,23 @@ namespace runtime {
|
||||||
public:
|
public:
|
||||||
Recognizer();
|
Recognizer();
|
||||||
|
|
||||||
private:
|
/** Used to print out token names like ID during debugging and
|
||||||
static std::map<std::vector<std::wstring>, std::map<std::wstring, size_t>> _tokenTypeMapCache;
|
* error reporting. The generated parsers implement a method
|
||||||
static std::map<std::vector<std::wstring>, std::map<std::wstring, size_t>> _ruleIndexMapCache;
|
* that overrides this to point to their String[] tokenNames.
|
||||||
|
*
|
||||||
ProxyErrorListener _proxListener; // Manages a collection of listeners.
|
* @deprecated Use {@link #getVocabulary()} instead.
|
||||||
|
*/
|
||||||
// Mutex to manage synchronized access for multithreading.
|
|
||||||
std::mutex mtx;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
atn::ATNSimulator *_interpreter; // Set and deleted in descendants.
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _stateNumber;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to print out token names like ID during debugging and
|
|
||||||
/// error reporting. The generated parsers implement a method
|
|
||||||
/// that overrides this to point to their generated token names list.
|
|
||||||
/// </summary>
|
|
||||||
public:
|
|
||||||
virtual const std::vector<std::wstring>& getTokenNames() const = 0;
|
virtual const std::vector<std::wstring>& getTokenNames() const = 0;
|
||||||
|
|
||||||
virtual const std::vector<std::wstring>& getRuleNames() const = 0;
|
virtual const std::vector<std::wstring>& getRuleNames() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the vocabulary used by the recognizer.
|
||||||
|
*
|
||||||
|
* @return A {@link Vocabulary} instance providing information about the
|
||||||
|
* vocabulary used by the grammar.
|
||||||
|
*/
|
||||||
|
Ref<dfa::Vocabulary> getVocabulary() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a map from token names to token types.
|
/// Get a map from token names to token types.
|
||||||
/// <p/>
|
/// <p/>
|
||||||
|
@ -108,19 +100,37 @@ namespace runtime {
|
||||||
return dynamic_cast<T *>(_interpreter);
|
return dynamic_cast<T *>(_interpreter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/** If profiling during the parse/lex, this will return DecisionInfo records
|
||||||
/// What is the error header, normally line/character position information? </summary>
|
* for each decision in recognizer in a ParseInfo object.
|
||||||
|
*
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
virtual Ref<atn::ParseInfo> getParseInfo() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the ATN interpreter used by the recognizer for prediction.
|
||||||
|
*
|
||||||
|
* @param interpreter The ATN interpreter used by the recognizer for
|
||||||
|
* prediction.
|
||||||
|
*/
|
||||||
|
void setInterpreter(atn::ATNSimulator *interpreter);
|
||||||
|
|
||||||
|
/// What is the error header, normally line/character position information?
|
||||||
virtual std::wstring getErrorHeader(RecognitionException *e);
|
virtual std::wstring getErrorHeader(RecognitionException *e);
|
||||||
|
|
||||||
/// <summary>
|
/** How should a token be displayed in an error message? The default
|
||||||
/// How should a token be displayed in an error message? The default
|
* is to display just the text, but during development you might
|
||||||
/// is to display just the text, but during development you might
|
* want to have a lot of information spit out. Override in that case
|
||||||
/// want to have a lot of information spit out. Override in that case
|
* to use t.toString() (which, for CommonToken, dumps everything about
|
||||||
/// to use t.toString() (which, for CommonToken, dumps everything about
|
* the token). This is better than forcing you to override a method in
|
||||||
/// the token). This is better than forcing you to override a method in
|
* your token objects because you don't have to go modify your lexer
|
||||||
/// your token objects because you don't have to go modify your lexer
|
* so that it creates a new Java type.
|
||||||
/// so that it creates a new Java type.
|
*
|
||||||
/// </summary>
|
* @deprecated This method is not called by the ANTLR 4 Runtime. Specific
|
||||||
|
* implementations of {@link ANTLRErrorStrategy} may provide a similar
|
||||||
|
* feature when necessary. For example, see
|
||||||
|
* {@link DefaultErrorStrategy#getTokenErrorDisplay}.
|
||||||
|
*/
|
||||||
virtual std::wstring getTokenErrorDisplay(Token *t);
|
virtual std::wstring getTokenErrorDisplay(Token *t);
|
||||||
|
|
||||||
/// <exception cref="NullPointerException"> if {@code listener} is {@code null}. </exception>
|
/// <exception cref="NullPointerException"> if {@code listener} is {@code null}. </exception>
|
||||||
|
@ -134,11 +144,11 @@ namespace runtime {
|
||||||
|
|
||||||
// subclass needs to override these if there are sempreds or actions
|
// subclass needs to override these if there are sempreds or actions
|
||||||
// that the ATN interp needs to execute
|
// that the ATN interp needs to execute
|
||||||
virtual bool sempred(RuleContext::Ref localctx, int ruleIndex, int actionIndex);
|
virtual bool sempred(Ref<RuleContext> localctx, int ruleIndex, int actionIndex);
|
||||||
|
|
||||||
virtual bool precpred(RuleContext::Ref localctx, int precedence);
|
virtual bool precpred(Ref<RuleContext> localctx, int precedence);
|
||||||
|
|
||||||
virtual void action(RuleContext::Ref localctx, int ruleIndex, int actionIndex);
|
virtual void action(Ref<RuleContext> localctx, int ruleIndex, int actionIndex);
|
||||||
|
|
||||||
int getState();
|
int getState();
|
||||||
|
|
||||||
|
@ -156,12 +166,25 @@ namespace runtime {
|
||||||
|
|
||||||
virtual void setInputStream(IntStream *input) = 0;
|
virtual void setInputStream(IntStream *input) = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<TokenFactory<CommonToken>> getTokenFactory() = 0;
|
virtual Ref<TokenFactory<CommonToken>> getTokenFactory() = 0;
|
||||||
|
|
||||||
template<typename T1>
|
template<typename T1>
|
||||||
void setTokenFactory(TokenFactory<T1> *input);
|
void setTokenFactory(TokenFactory<T1> *input);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
atn::ATNSimulator *_interpreter; // Set and deleted in descendants (or the profiler).
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static std::map<Ref<dfa::Vocabulary>, std::map<std::wstring, size_t>> _tokenTypeMapCache;
|
||||||
|
static std::map<std::vector<std::wstring>, std::map<std::wstring, size_t>> _ruleIndexMapCache;
|
||||||
|
|
||||||
|
ProxyErrorListener _proxListener; // Manages a collection of listeners.
|
||||||
|
|
||||||
|
// Mutex to manage synchronized access for multithreading.
|
||||||
|
std::mutex mtx;
|
||||||
|
|
||||||
|
int _stateNumber;
|
||||||
|
|
||||||
void InitializeInstanceFields();
|
void InitializeInstanceFields();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,12 +32,13 @@
|
||||||
#include "Trees.h"
|
#include "Trees.h"
|
||||||
#include "Interval.h"
|
#include "Interval.h"
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
|
#include "ATN.h"
|
||||||
|
|
||||||
#include "RuleContext.h"
|
#include "RuleContext.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
|
||||||
const RuleContext::Ref RuleContext::EMPTY = std::make_shared<ParserRuleContext>();
|
const Ref<RuleContext> RuleContext::EMPTY = std::make_shared<ParserRuleContext>();
|
||||||
|
|
||||||
RuleContext::RuleContext() {
|
RuleContext::RuleContext() {
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
|
@ -51,7 +52,7 @@ RuleContext::RuleContext(std::weak_ptr<RuleContext> parent, int invokingState) {
|
||||||
|
|
||||||
int RuleContext::depth() {
|
int RuleContext::depth() {
|
||||||
int n = 1;
|
int n = 1;
|
||||||
RuleContext::Ref p = shared_from_this();
|
Ref<RuleContext> p = shared_from_this();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (p->parent.expired())
|
if (p->parent.expired())
|
||||||
break;
|
break;
|
||||||
|
@ -69,7 +70,7 @@ misc::Interval RuleContext::getSourceInterval() {
|
||||||
return misc::Interval::INVALID;
|
return misc::Interval::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleContext::Ref RuleContext::getRuleContext() {
|
Ref<RuleContext> RuleContext::getRuleContext() {
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,43 +98,22 @@ ssize_t RuleContext::getRuleIndex() const {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<tree::Tree> RuleContext::getChildReference(size_t i) {
|
Ref<tree::Tree> RuleContext::getChildReference(size_t i) {
|
||||||
return std::shared_ptr<tree::Tree>();
|
return Ref<tree::Tree>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int RuleContext::getAltNumber() const {
|
||||||
|
return atn::ATN::INVALID_ALT_NUMBER;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RuleContext::setAltNumber(int altNumber) {
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t RuleContext::getChildCount() {
|
std::size_t RuleContext::getChildCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleContext::save(Parser *parser, const std::wstring &fileName) {
|
|
||||||
std::vector<std::wstring> ruleNames;
|
|
||||||
if (parser != nullptr) {
|
|
||||||
ruleNames = parser->getRuleNames();
|
|
||||||
}
|
|
||||||
save(ruleNames, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleContext::save(Parser *parser, const std::wstring &fileName, const std::wstring &fontName, int fontSize) {
|
|
||||||
std::vector<std::wstring> ruleNames;
|
|
||||||
if (parser != nullptr) {
|
|
||||||
ruleNames = parser->getRuleNames();
|
|
||||||
}
|
|
||||||
save(ruleNames, fileName, fontName, fontSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleContext::save(std::vector<std::wstring> &ruleNames, const std::wstring &fileName) {
|
|
||||||
#ifdef TODO
|
|
||||||
tree::Trees::writePS(this, ruleNames, fileName);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleContext::save(std::vector<std::wstring> &ruleNames, const std::wstring &fileName, const std::wstring &fontName, int fontSize) {
|
|
||||||
#ifdef TODO
|
|
||||||
tree::Trees::writePS(this, ruleNames, fileName, fontName, fontSize);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring RuleContext::toStringTree(Parser *recog) {
|
std::wstring RuleContext::toStringTree(Parser *recog) {
|
||||||
return tree::Trees::toStringTree(shared_from_this(), recog);
|
return tree::Trees::toStringTree(shared_from_this(), recog);
|
||||||
}
|
}
|
||||||
|
@ -148,14 +128,14 @@ std::wstring RuleContext::toStringTree() {
|
||||||
|
|
||||||
|
|
||||||
std::wstring RuleContext::toString(const std::vector<std::wstring> &ruleNames) {
|
std::wstring RuleContext::toString(const std::vector<std::wstring> &ruleNames) {
|
||||||
return toString(ruleNames, RuleContext::Ref());
|
return toString(ruleNames, Ref<RuleContext>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::wstring RuleContext::toString(const std::vector<std::wstring> &ruleNames, RuleContext::Ref stop) {
|
std::wstring RuleContext::toString(const std::vector<std::wstring> &ruleNames, Ref<RuleContext> stop) {
|
||||||
std::wstringstream ss;
|
std::wstringstream ss;
|
||||||
|
|
||||||
RuleContext::Ref parent = shared_from_this();
|
Ref<RuleContext> parent = shared_from_this();
|
||||||
ss << L"[";
|
ss << L"[";
|
||||||
while (parent != stop) {
|
while (parent != stop) {
|
||||||
if (ruleNames.empty()) {
|
if (ruleNames.empty()) {
|
||||||
|
@ -190,7 +170,7 @@ std::wstring RuleContext::toString(Recognizer *recog) {
|
||||||
return toString(recog, ParserRuleContext::EMPTY);
|
return toString(recog, ParserRuleContext::EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring RuleContext::toString(Recognizer *recog, RuleContext::Ref stop) {
|
std::wstring RuleContext::toString(Recognizer *recog, Ref<RuleContext> stop) {
|
||||||
if (recog == nullptr)
|
if (recog == nullptr)
|
||||||
return toString({}, stop);
|
return toString({}, stop);
|
||||||
return toString(recog->getRuleNames(), stop);
|
return toString(recog->getRuleNames(), stop);
|
||||||
|
|
|
@ -38,41 +38,66 @@ namespace antlr {
|
||||||
namespace v4 {
|
namespace v4 {
|
||||||
namespace runtime {
|
namespace runtime {
|
||||||
|
|
||||||
/// <summary>
|
/** A rule context is a record of a single rule invocation.
|
||||||
/// A rule context is a record of a single rule invocation. It knows
|
*
|
||||||
/// which context invoked it, if any. If there is no parent context, then
|
* We form a stack of these context objects using the parent
|
||||||
/// naturally the invoking state is not valid. The parent link
|
* pointer. A parent pointer of null indicates that the current
|
||||||
/// provides a chain upwards from the current rule invocation to the root
|
* context is the bottom of the stack. The ParserRuleContext subclass
|
||||||
/// of the invocation tree, forming a stack. We actually carry no
|
* as a children list so that we can turn this data structure into a
|
||||||
/// information about the rule associated with this context (except
|
* tree.
|
||||||
/// when parsing). We keep only the state number of the invoking state from
|
*
|
||||||
/// the ATN submachine that invoked this. Contrast this with the s
|
* The root node always has a null pointer and invokingState of -1.
|
||||||
/// pointer inside ParserRuleContext that tracks the current state
|
*
|
||||||
/// being "executed" for the current rule.
|
* Upon entry to parsing, the first invoked rule function creates a
|
||||||
///
|
* context object (asubclass specialized for that rule such as
|
||||||
/// The parent contexts are useful for computing lookahead sets and
|
* SContext) and makes it the root of a parse tree, recorded by field
|
||||||
/// getting error information.
|
* Parser._ctx.
|
||||||
///
|
*
|
||||||
/// These objects are used during parsing and prediction.
|
* public final SContext s() throws RecognitionException {
|
||||||
/// For the special case of parsers, we use the subclass
|
* SContext _localctx = new SContext(_ctx, getState()); <-- create new node
|
||||||
/// ParserRuleContext.
|
* enterRule(_localctx, 0, RULE_s); <-- push it
|
||||||
/// </summary>
|
* ...
|
||||||
/// <seealso cref= ParserRuleContext </seealso>
|
* exitRule(); <-- pop back to _localctx
|
||||||
|
* return _localctx;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* A subsequent rule invocation of r from the start rule s pushes a
|
||||||
|
* new context object for r whose parent points at s and use invoking
|
||||||
|
* state is the state with r emanating as edge label.
|
||||||
|
*
|
||||||
|
* The invokingState fields from a context object to the root
|
||||||
|
* together form a stack of rule indication states where the root
|
||||||
|
* (bottom of the stack) has a -1 sentinel value. If we invoke start
|
||||||
|
* symbol s then call r1, which calls r2, the would look like
|
||||||
|
* this:
|
||||||
|
*
|
||||||
|
* SContext[-1] <- root node (bottom of the stack)
|
||||||
|
* R1Context[p] <- p in rule s called r1
|
||||||
|
* R2Context[q] <- q in rule r1 called r2
|
||||||
|
*
|
||||||
|
* So the top of the stack, _ctx, represents a call to the current
|
||||||
|
* rule and it holds the return address from another rule that invoke
|
||||||
|
* to this rule. To invoke a rule, we must always have a current context.
|
||||||
|
*
|
||||||
|
* The parent contexts are useful for computing lookahead sets and
|
||||||
|
* getting error information.
|
||||||
|
*
|
||||||
|
* These objects are used during parsing and prediction.
|
||||||
|
* For the special case of parsers, we use the subclass
|
||||||
|
* ParserRuleContext.
|
||||||
|
*
|
||||||
|
* @see ParserRuleContext
|
||||||
|
*/
|
||||||
class RuleContext : public tree::RuleNode, public std::enable_shared_from_this<RuleContext> {
|
class RuleContext : public tree::RuleNode, public std::enable_shared_from_this<RuleContext> {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<RuleContext> Ref;
|
static const Ref<RuleContext> EMPTY;
|
||||||
|
|
||||||
static const RuleContext::Ref EMPTY;
|
/// What context invoked this rule?
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// What context invoked this rule? </summary>
|
|
||||||
std::weak_ptr<RuleContext> parent;
|
std::weak_ptr<RuleContext> parent;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// What state invoked the rule associated with this context?
|
/// What state invoked the rule associated with this context?
|
||||||
/// The "return address" is the followState of invokingState
|
/// The "return address" is the followState of invokingState
|
||||||
/// If parent is null, this should be -1.
|
/// If parent is null, this should be -1 and this context object represents the start rule.
|
||||||
/// </summary>
|
|
||||||
int invokingState;
|
int invokingState;
|
||||||
|
|
||||||
RuleContext();
|
RuleContext();
|
||||||
|
@ -81,18 +106,39 @@ namespace runtime {
|
||||||
|
|
||||||
virtual int depth();
|
virtual int depth();
|
||||||
|
|
||||||
/// A context is empty if there is no invoking state; meaning nobody call current context.
|
/// A context is empty if there is no invoking state; meaning nobody called current context.
|
||||||
virtual bool isEmpty();
|
virtual bool isEmpty();
|
||||||
|
|
||||||
// satisfy the ParseTree / SyntaxTree interface
|
// satisfy the ParseTree / SyntaxTree interface
|
||||||
|
|
||||||
virtual misc::Interval getSourceInterval() override;
|
virtual misc::Interval getSourceInterval() override;
|
||||||
|
|
||||||
virtual RuleContext::Ref getRuleContext() override;
|
virtual Ref<RuleContext> getRuleContext() override;
|
||||||
virtual std::wstring getText() override;
|
virtual std::wstring getText() override;
|
||||||
|
|
||||||
virtual ssize_t getRuleIndex() const;
|
virtual ssize_t getRuleIndex() const;
|
||||||
|
|
||||||
|
/** For rule associated with this parse tree internal node, return
|
||||||
|
* the outer alternative number used to match the input. Default
|
||||||
|
* implementation does not compute nor store this alt num. Create
|
||||||
|
* a subclass of ParserRuleContext with backing field and set
|
||||||
|
* option contextSuperClass.
|
||||||
|
* to set it.
|
||||||
|
*
|
||||||
|
* @since 4.5.3
|
||||||
|
*/
|
||||||
|
virtual int getAltNumber() const;
|
||||||
|
|
||||||
|
/** Set the outer alternative number for this context node. Default
|
||||||
|
* implementation does nothing to avoid backing field overhead for
|
||||||
|
* trees that don't need it. Create
|
||||||
|
* a subclass of ParserRuleContext with backing field and set
|
||||||
|
* option contextSuperClass.
|
||||||
|
*
|
||||||
|
* @since 4.5.3
|
||||||
|
*/
|
||||||
|
virtual void setAltNumber(int altNumber);
|
||||||
|
|
||||||
virtual std::size_t getChildCount() override;
|
virtual std::size_t getChildCount() override;
|
||||||
|
|
||||||
template<typename T, typename T1>
|
template<typename T, typename T1>
|
||||||
|
@ -100,22 +146,6 @@ namespace runtime {
|
||||||
return visitor->visitChildren(this);
|
return visitor->visitChildren(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Save this tree in a postscript file </summary>
|
|
||||||
virtual void save(Parser *parser, const std::wstring &fileName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Save this tree in a postscript file using a particular font name and size </summary>
|
|
||||||
virtual void save(Parser *parser, const std::wstring &fileName, const std::wstring &fontName, int fontSize);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Save this tree in a postscript file </summary>
|
|
||||||
virtual void save(std::vector<std::wstring> &ruleNames, const std::wstring &fileName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Save this tree in a postscript file using a particular font name and size </summary>
|
|
||||||
virtual void save(std::vector<std::wstring> &ruleNames, const std::wstring &fileName, const std::wstring &fontName, int fontSize);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Print out a whole tree, not just a node, in LISP format
|
/// Print out a whole tree, not just a node, in LISP format
|
||||||
/// (root child1 .. childN). Print just a node if this is a leaf.
|
/// (root child1 .. childN). Print just a node if this is a leaf.
|
||||||
|
@ -135,15 +165,15 @@ namespace runtime {
|
||||||
std::wstring toString(const std::vector<std::wstring> &ruleNames);
|
std::wstring toString(const std::vector<std::wstring> &ruleNames);
|
||||||
|
|
||||||
// recog null unless ParserRuleContext, in which case we use subclass toString(...)
|
// recog null unless ParserRuleContext, in which case we use subclass toString(...)
|
||||||
std::wstring toString(Recognizer *recog, RuleContext::Ref stop);
|
std::wstring toString(Recognizer *recog, Ref<RuleContext> stop);
|
||||||
|
|
||||||
virtual std::wstring toString(const std::vector<std::wstring> &ruleNames, RuleContext::Ref stop);
|
virtual std::wstring toString(const std::vector<std::wstring> &ruleNames, Ref<RuleContext> stop);
|
||||||
|
|
||||||
bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
|
bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::weak_ptr<Tree> getParentReference() override;
|
virtual std::weak_ptr<Tree> getParentReference() override;
|
||||||
virtual std::shared_ptr<Tree> getChildReference(size_t i) override;
|
virtual Ref<Tree> getChildReference(size_t i) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeInstanceFields();
|
void InitializeInstanceFields();
|
||||||
|
|
|
@ -45,8 +45,6 @@ namespace runtime {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class Token {
|
class Token {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<Token> Ref;
|
|
||||||
|
|
||||||
static const size_t INVALID_TYPE = 0;
|
static const size_t INVALID_TYPE = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -47,10 +47,10 @@ namespace runtime {
|
||||||
/// are wiped to -1 in the text override is set in the CommonToken.
|
/// are wiped to -1 in the text override is set in the CommonToken.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public:
|
public:
|
||||||
virtual std::shared_ptr<Symbol> create(std::pair<TokenSource*, CharStream*> source, int type, const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) = 0;
|
virtual Ref<Symbol> create(std::pair<TokenSource*, CharStream*> source, int type, const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) = 0;
|
||||||
|
|
||||||
/// Generically useful
|
/// Generically useful
|
||||||
virtual std::shared_ptr<Symbol> create(int type, const std::wstring &text) = 0;
|
virtual Ref<Symbol> create(int type, const std::wstring &text) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Token.h"
|
|
||||||
#include "TokenFactory.h"
|
#include "TokenFactory.h"
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
|
@ -62,7 +61,7 @@ namespace runtime {
|
||||||
/// to the parser.
|
/// to the parser.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public:
|
public:
|
||||||
virtual Token::Ref nextToken() = 0;
|
virtual Ref<Token> nextToken() = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the line number for the current position in the input stream. The
|
/// Get the line number for the current position in the input stream. The
|
||||||
|
@ -109,7 +108,7 @@ namespace runtime {
|
||||||
/// creating <seealso cref="Token"/> objects from the input.
|
/// creating <seealso cref="Token"/> objects from the input.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns> The <seealso cref="TokenFactory"/> currently used by this token source. </returns>
|
/// <returns> The <seealso cref="TokenFactory"/> currently used by this token source. </returns>
|
||||||
virtual std::shared_ptr<TokenFactory<CommonToken>> getTokenFactory() = 0;
|
virtual Ref<TokenFactory<CommonToken>> getTokenFactory() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Token.h"
|
|
||||||
#include "IntStream.h"
|
#include "IntStream.h"
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
|
@ -54,7 +53,7 @@ namespace runtime {
|
||||||
public:
|
public:
|
||||||
virtual ~TokenStream();
|
virtual ~TokenStream();
|
||||||
|
|
||||||
virtual Token::Ref LT(ssize_t k) = 0;
|
virtual Ref<Token> LT(ssize_t k) = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <seealso cref="Token"/> at the specified {@code index} in the stream. When
|
/// Gets the <seealso cref="Token"/> at the specified {@code index} in the stream. When
|
||||||
|
@ -73,7 +72,7 @@ namespace runtime {
|
||||||
/// <exception cref="IllegalArgumentException"> if {code index} is less than 0 </exception>
|
/// <exception cref="IllegalArgumentException"> if {code index} is less than 0 </exception>
|
||||||
/// <exception cref="UnsupportedOperationException"> if the stream does not support
|
/// <exception cref="UnsupportedOperationException"> if the stream does not support
|
||||||
/// retrieving the token at the specified index </exception>
|
/// retrieving the token at the specified index </exception>
|
||||||
virtual Token::Ref get(size_t index) const = 0;
|
virtual Ref<Token> get(size_t index) const = 0;
|
||||||
|
|
||||||
/// Gets the underlying TokenSource which provides tokens for this stream.
|
/// Gets the underlying TokenSource which provides tokens for this stream.
|
||||||
virtual TokenSource* getTokenSource() const = 0;
|
virtual TokenSource* getTokenSource() const = 0;
|
||||||
|
@ -161,7 +160,7 @@ namespace runtime {
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="UnsupportedOperationException"> if this stream does not support
|
/// <exception cref="UnsupportedOperationException"> if this stream does not support
|
||||||
/// this method for the specified tokens </exception>
|
/// this method for the specified tokens </exception>
|
||||||
virtual std::wstring getText(Token::Ref start, Token::Ref stop) = 0;
|
virtual std::wstring getText(Ref<Token> start, Ref<Token> stop) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace runtime
|
} // namespace runtime
|
||||||
|
|
|
@ -299,7 +299,7 @@ std::wstring TokenStreamRewriter::getText(const std::wstring &programName, const
|
||||||
while (i <= (size_t)stop && i < tokens->size()) {
|
while (i <= (size_t)stop && i < tokens->size()) {
|
||||||
RewriteOperation *op = indexToOp[i];
|
RewriteOperation *op = indexToOp[i];
|
||||||
indexToOp.erase(i); // remove so any left have index size-1
|
indexToOp.erase(i); // remove so any left have index size-1
|
||||||
Token::Ref t = tokens->get(i);
|
Ref<Token> t = tokens->get(i);
|
||||||
if (op == nullptr) {
|
if (op == nullptr) {
|
||||||
// no operation at that index, just dump token
|
// no operation at that index, just dump token
|
||||||
if (t->getType() != EOF) {
|
if (t->getType() != EOF) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource, int buffe
|
||||||
UnbufferedTokenStream::~UnbufferedTokenStream() {
|
UnbufferedTokenStream::~UnbufferedTokenStream() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref UnbufferedTokenStream::get(size_t i) const
|
Ref<Token> UnbufferedTokenStream::get(size_t i) const
|
||||||
{ // get absolute index
|
{ // get absolute index
|
||||||
size_t bufferStartIndex = getBufferStartIndex();
|
size_t bufferStartIndex = getBufferStartIndex();
|
||||||
if (i < bufferStartIndex || i >= bufferStartIndex + _tokens.size()) {
|
if (i < bufferStartIndex || i >= bufferStartIndex + _tokens.size()) {
|
||||||
|
@ -64,7 +64,7 @@ Token::Ref UnbufferedTokenStream::get(size_t i) const
|
||||||
return _tokens[i - bufferStartIndex];
|
return _tokens[i - bufferStartIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref UnbufferedTokenStream::LT(ssize_t i)
|
Ref<Token> UnbufferedTokenStream::LT(ssize_t i)
|
||||||
{
|
{
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
return _lastToken;
|
return _lastToken;
|
||||||
|
@ -104,7 +104,7 @@ std::wstring UnbufferedTokenStream::getText(RuleContext* ctx)
|
||||||
return getText(ctx->getSourceInterval());
|
return getText(ctx->getSourceInterval());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring UnbufferedTokenStream::getText(Token::Ref start, Token::Ref stop)
|
std::wstring UnbufferedTokenStream::getText(Ref<Token> start, Ref<Token> stop)
|
||||||
{
|
{
|
||||||
return getText(misc::Interval(start->getTokenIndex(), stop->getTokenIndex()));
|
return getText(misc::Interval(start->getTokenIndex(), stop->getTokenIndex()));
|
||||||
}
|
}
|
||||||
|
@ -156,16 +156,16 @@ size_t UnbufferedTokenStream::fill(size_t n)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Ref t = _tokenSource->nextToken();
|
Ref<Token> t = _tokenSource->nextToken();
|
||||||
add(t);
|
add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnbufferedTokenStream::add(Token::Ref t)
|
void UnbufferedTokenStream::add(Ref<Token> t)
|
||||||
{
|
{
|
||||||
WritableToken::Ref writable = std::dynamic_pointer_cast<WritableToken>(t);
|
Ref<WritableToken> writable = std::dynamic_pointer_cast<WritableToken>(t);
|
||||||
if (writable) {
|
if (writable) {
|
||||||
writable->setTokenIndex(int(getBufferStartIndex() + _tokens.size()));
|
writable->setTokenIndex(int(getBufferStartIndex() + _tokens.size()));
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ void UnbufferedTokenStream::release(ssize_t marker)
|
||||||
if (_p > 0) {
|
if (_p > 0) {
|
||||||
// Copy tokens[p]..tokens[n-1] to tokens[0]..tokens[(n-1)-p], reset ptrs
|
// Copy tokens[p]..tokens[n-1] to tokens[0]..tokens[(n-1)-p], reset ptrs
|
||||||
// p is last valid token; move nothing if p==n as we have no valid char
|
// p is last valid token; move nothing if p==n as we have no valid char
|
||||||
std::vector<Token::Ref>(_tokens.begin() + (ssize_t)_p, _tokens.end()).swap(_tokens);
|
std::vector<Ref<Token>>(_tokens.begin() + (ssize_t)_p, _tokens.end()).swap(_tokens);
|
||||||
_p = 0;
|
_p = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ std::wstring UnbufferedTokenStream::getText(const misc::Interval &interval)
|
||||||
|
|
||||||
std::wstringstream ss;
|
std::wstringstream ss;
|
||||||
for (size_t i = a; i <= b; i++) {
|
for (size_t i = a; i <= b; i++) {
|
||||||
Token::Ref t = _tokens[i];
|
Ref<Token> t = _tokens[i];
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
ss << L", ";
|
ss << L", ";
|
||||||
ss << t->getText();
|
ss << t->getText();
|
||||||
|
|
|
@ -44,8 +44,8 @@ namespace runtime {
|
||||||
UnbufferedTokenStream(TokenSource *tokenSource, int bufferSize);
|
UnbufferedTokenStream(TokenSource *tokenSource, int bufferSize);
|
||||||
virtual ~UnbufferedTokenStream();
|
virtual ~UnbufferedTokenStream();
|
||||||
|
|
||||||
virtual Token::Ref get(size_t i) const override;
|
virtual Ref<Token> get(size_t i) const override;
|
||||||
virtual Token::Ref LT(ssize_t i) override;
|
virtual Ref<Token> LT(ssize_t i) override;
|
||||||
virtual ssize_t LA(ssize_t i) override;
|
virtual ssize_t LA(ssize_t i) override;
|
||||||
|
|
||||||
virtual TokenSource* getTokenSource() const override;
|
virtual TokenSource* getTokenSource() const override;
|
||||||
|
@ -53,7 +53,7 @@ namespace runtime {
|
||||||
virtual std::wstring getText(const misc::Interval &interval) override;
|
virtual std::wstring getText(const misc::Interval &interval) override;
|
||||||
virtual std::wstring getText() override;
|
virtual std::wstring getText() override;
|
||||||
virtual std::wstring getText(RuleContext *ctx) override;
|
virtual std::wstring getText(RuleContext *ctx) override;
|
||||||
virtual std::wstring getText(Token::Ref start, Token::Ref stop) override;
|
virtual std::wstring getText(Ref<Token> start, Ref<Token> stop) override;
|
||||||
|
|
||||||
virtual void consume() override;
|
virtual void consume() override;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ namespace runtime {
|
||||||
/// we start filling at index 0 again.
|
/// we start filling at index 0 again.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
std::vector<Token::Ref> _tokens;
|
std::vector<Ref<Token>> _tokens;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 0..n-1 index into <seealso cref="#tokens tokens"/> of next token.
|
/// 0..n-1 index into <seealso cref="#tokens tokens"/> of next token.
|
||||||
|
@ -104,13 +104,13 @@ namespace runtime {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the {@code LT(-1)} token for the current position.
|
/// This is the {@code LT(-1)} token for the current position.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Token::Ref _lastToken;
|
Ref<Token> _lastToken;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When {@code numMarkers > 0}, this is the {@code LT(-1)} token for the
|
/// When {@code numMarkers > 0}, this is the {@code LT(-1)} token for the
|
||||||
/// first token in <seealso cref="#tokens"/>. Otherwise, this is {@code null}.
|
/// first token in <seealso cref="#tokens"/>. Otherwise, this is {@code null}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Token::Ref _lastTokenBufferStart;
|
Ref<Token> _lastTokenBufferStart;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Absolute token index. It's the index of the token about to be read via
|
/// Absolute token index. It's the index of the token about to be read via
|
||||||
|
@ -130,7 +130,7 @@ namespace runtime {
|
||||||
/// then EOF was reached before {@code n} tokens could be added.
|
/// then EOF was reached before {@code n} tokens could be added.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual size_t fill(size_t n);
|
virtual size_t fill(size_t n);
|
||||||
virtual void add(Token::Ref t);
|
virtual void add(Ref<Token> t);
|
||||||
|
|
||||||
size_t getBufferStartIndex() const;
|
size_t getBufferStartIndex() const;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace dfa {
|
||||||
|
|
||||||
|
/// This interface provides information about the vocabulary used by a
|
||||||
|
/// recognizer.
|
||||||
|
///
|
||||||
|
/// <seealso cref= Recognizer#getVocabulary()
|
||||||
|
/// @author Sam Harwell </seealso>
|
||||||
|
class Vocabulary {
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the highest token type value. It can be used to iterate from
|
||||||
|
/// zero to that number, inclusively, thus querying all stored entries. </summary>
|
||||||
|
/// <returns> the highest token type value </returns>
|
||||||
|
virtual int getMaxTokenType() const = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the string literal associated with a token type. The string returned
|
||||||
|
/// by this method, when not {@code null}, can be used unaltered in a parser
|
||||||
|
/// grammar to represent this token type.
|
||||||
|
///
|
||||||
|
/// <para>The following table shows examples of lexer rules and the literal
|
||||||
|
/// names assigned to the corresponding token types.</para>
|
||||||
|
///
|
||||||
|
/// <table>
|
||||||
|
/// <tr>
|
||||||
|
/// <th>Rule</th>
|
||||||
|
/// <th>Literal Name</th>
|
||||||
|
/// <th>Java String Literal</th>
|
||||||
|
/// </tr>
|
||||||
|
/// <tr>
|
||||||
|
/// <td>{@code THIS : 'this';}</td>
|
||||||
|
/// <td>{@code 'this'}</td>
|
||||||
|
/// <td>{@code "'this'"}</td>
|
||||||
|
/// </tr>
|
||||||
|
/// <tr>
|
||||||
|
/// <td>{@code SQUOTE : '\'';}</td>
|
||||||
|
/// <td>{@code '\''}</td>
|
||||||
|
/// <td>{@code "'\\''"}</td>
|
||||||
|
/// </tr>
|
||||||
|
/// <tr>
|
||||||
|
/// <td>{@code ID : [A-Z]+;}</td>
|
||||||
|
/// <td>n/a</td>
|
||||||
|
/// <td>{@code null}</td>
|
||||||
|
/// </tr>
|
||||||
|
/// </table>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tokenType"> The token type.
|
||||||
|
/// </param>
|
||||||
|
/// <returns> The string literal associated with the specified token type, or
|
||||||
|
/// {@code null} if no string literal is associated with the type. </returns>
|
||||||
|
virtual std::wstring getLiteralName(ssize_t tokenType) const = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the symbolic name associated with a token type. The string returned
|
||||||
|
/// by this method, when not {@code null}, can be used unaltered in a parser
|
||||||
|
/// grammar to represent this token type.
|
||||||
|
///
|
||||||
|
/// <para>This method supports token types defined by any of the following
|
||||||
|
/// methods:</para>
|
||||||
|
///
|
||||||
|
/// <ul>
|
||||||
|
/// <li>Tokens created by lexer rules.</li>
|
||||||
|
/// <li>Tokens defined in a <code>tokens{}</code> block in a lexer or parser
|
||||||
|
/// grammar.</li>
|
||||||
|
/// <li>The implicitly defined {@code EOF} token, which has the token type
|
||||||
|
/// <seealso cref="Token#EOF"/>.</li>
|
||||||
|
/// </ul>
|
||||||
|
///
|
||||||
|
/// <para>The following table shows examples of lexer rules and the literal
|
||||||
|
/// names assigned to the corresponding token types.</para>
|
||||||
|
///
|
||||||
|
/// <table>
|
||||||
|
/// <tr>
|
||||||
|
/// <th>Rule</th>
|
||||||
|
/// <th>Symbolic Name</th>
|
||||||
|
/// </tr>
|
||||||
|
/// <tr>
|
||||||
|
/// <td>{@code THIS : 'this';}</td>
|
||||||
|
/// <td>{@code THIS}</td>
|
||||||
|
/// </tr>
|
||||||
|
/// <tr>
|
||||||
|
/// <td>{@code SQUOTE : '\'';}</td>
|
||||||
|
/// <td>{@code SQUOTE}</td>
|
||||||
|
/// </tr>
|
||||||
|
/// <tr>
|
||||||
|
/// <td>{@code ID : [A-Z]+;}</td>
|
||||||
|
/// <td>{@code ID}</td>
|
||||||
|
/// </tr>
|
||||||
|
/// </table>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tokenType"> The token type.
|
||||||
|
/// </param>
|
||||||
|
/// <returns> The symbolic name associated with the specified token type, or
|
||||||
|
/// {@code null} if no symbolic name is associated with the type. </returns>
|
||||||
|
virtual std::wstring getSymbolicName(ssize_t tokenType) const = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the display name of a token type.
|
||||||
|
///
|
||||||
|
/// <para>ANTLR provides a default implementation of this method, but
|
||||||
|
/// applications are free to override the behavior in any manner which makes
|
||||||
|
/// sense for the application. The default implementation returns the first
|
||||||
|
/// result from the following list which produces a non-{@code null}
|
||||||
|
/// result.</para>
|
||||||
|
///
|
||||||
|
/// <ol>
|
||||||
|
/// <li>The result of <seealso cref="#getLiteralName"/></li>
|
||||||
|
/// <li>The result of <seealso cref="#getSymbolicName"/></li>
|
||||||
|
/// <li>The result of <seealso cref="Integer#toString"/></li>
|
||||||
|
/// </ol>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tokenType"> The token type.
|
||||||
|
/// </param>
|
||||||
|
/// <returns> The display name of the token type, for use in error reporting or
|
||||||
|
/// other user-visible messages which reference specific token types. </returns>
|
||||||
|
virtual std::wstring getDisplayName(ssize_t tokenType) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "VocabularyImpl.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime::dfa;
|
||||||
|
|
||||||
|
const std::vector<std::wstring> VocabularyImpl::EMPTY_NAMES;
|
||||||
|
const Ref<Vocabulary> VocabularyImpl::EMPTY_VOCABULARY = std::make_shared<VocabularyImpl>(EMPTY_NAMES, EMPTY_NAMES, EMPTY_NAMES);
|
||||||
|
|
||||||
|
VocabularyImpl::VocabularyImpl(const std::vector<std::wstring> &literalNames, const std::vector<std::wstring> &symbolicNames)
|
||||||
|
: VocabularyImpl(literalNames, symbolicNames, {}) {
|
||||||
|
}
|
||||||
|
|
||||||
|
VocabularyImpl::VocabularyImpl(const std::vector<std::wstring> &literalNames,
|
||||||
|
const std::vector<std::wstring> &symbolicNames, const std::vector<std::wstring> &displayNames)
|
||||||
|
: _literalNames(!literalNames.empty() ? literalNames : EMPTY_NAMES),
|
||||||
|
_symbolicNames(!symbolicNames.empty() ? symbolicNames : EMPTY_NAMES),
|
||||||
|
_displayNames(!displayNames.empty() ? displayNames : EMPTY_NAMES),
|
||||||
|
_maxTokenType(std::max((int)_displayNames.size(), std::max((int)_literalNames.size(), (int)_symbolicNames.size())) - 1) {
|
||||||
|
// See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Vocabulary> VocabularyImpl::fromTokenNames(const std::vector<std::wstring> &tokenNames) {
|
||||||
|
if (tokenNames.empty()) {
|
||||||
|
return EMPTY_VOCABULARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::wstring> literalNames = tokenNames;
|
||||||
|
std::vector<std::wstring> symbolicNames = tokenNames;
|
||||||
|
for (size_t i = 0; i < tokenNames.size(); i++) {
|
||||||
|
std::wstring tokenName = tokenNames[i];
|
||||||
|
if (tokenName == L"") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tokenName.empty()) {
|
||||||
|
wchar_t firstChar = tokenName[0];
|
||||||
|
if (firstChar == L'\'') {
|
||||||
|
symbolicNames[i] = L"";
|
||||||
|
continue;
|
||||||
|
} else if (std::isupper(firstChar)) {
|
||||||
|
literalNames[i] = L"";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wasn't a literal or symbolic name
|
||||||
|
literalNames[i] = L"";
|
||||||
|
symbolicNames[i] = L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_shared<VocabularyImpl>(literalNames, symbolicNames, tokenNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VocabularyImpl::getMaxTokenType() const {
|
||||||
|
return _maxTokenType;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring VocabularyImpl::getLiteralName(ssize_t tokenType) const {
|
||||||
|
if (tokenType >= 0 && tokenType < (int)_literalNames.size()) {
|
||||||
|
return _literalNames[tokenType];
|
||||||
|
}
|
||||||
|
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring VocabularyImpl::getSymbolicName(ssize_t tokenType) const {
|
||||||
|
if (tokenType >= 0 && tokenType < (int)_symbolicNames.size()) {
|
||||||
|
return _symbolicNames[tokenType];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tokenType == EOF) {
|
||||||
|
return L"EOF";
|
||||||
|
}
|
||||||
|
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring VocabularyImpl::getDisplayName(ssize_t tokenType) const {
|
||||||
|
if (tokenType >= 0 && tokenType < (int)_displayNames.size()) {
|
||||||
|
std::wstring displayName = _displayNames[tokenType];
|
||||||
|
if (!displayName.empty()) {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring literalName = getLiteralName(tokenType);
|
||||||
|
if (!literalName.empty()) {
|
||||||
|
return literalName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring symbolicName = getSymbolicName(tokenType);
|
||||||
|
if (!symbolicName.empty()) {
|
||||||
|
return symbolicName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::to_wstring(tokenType);
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Vocabulary.h"
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace dfa {
|
||||||
|
|
||||||
|
/// This class provides a default implementation of the <seealso cref="Vocabulary"/>
|
||||||
|
/// interface.
|
||||||
|
class VocabularyImpl : public Vocabulary {
|
||||||
|
public:
|
||||||
|
/// Gets an empty <seealso cref="Vocabulary"/> instance.
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// No literal or symbol names are assigned to token types, so
|
||||||
|
/// <seealso cref="#getDisplayName(int)"/> returns the numeric value for all tokens
|
||||||
|
/// except <seealso cref="Token#EOF"/>.</para>
|
||||||
|
static const Ref<Vocabulary> EMPTY_VOCABULARY;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance of <seealso cref="VocabularyImpl"/> from the specified
|
||||||
|
/// literal and symbolic token names.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="literalNames"> The literal names assigned to tokens, or {@code null}
|
||||||
|
/// if no literal names are assigned. </param>
|
||||||
|
/// <param name="symbolicNames"> The symbolic names assigned to tokens, or
|
||||||
|
/// {@code null} if no symbolic names are assigned.
|
||||||
|
/// </param>
|
||||||
|
/// <seealso cref= #getLiteralName(int) </seealso>
|
||||||
|
/// <seealso cref= #getSymbolicName(int) </seealso>
|
||||||
|
VocabularyImpl(const std::vector<std::wstring> &literalNames, const std::vector<std::wstring> &symbolicNames);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance of <seealso cref="VocabularyImpl"/> from the specified
|
||||||
|
/// literal, symbolic, and display token names.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="literalNames"> The literal names assigned to tokens, or {@code null}
|
||||||
|
/// if no literal names are assigned. </param>
|
||||||
|
/// <param name="symbolicNames"> The symbolic names assigned to tokens, or
|
||||||
|
/// {@code null} if no symbolic names are assigned. </param>
|
||||||
|
/// <param name="displayNames"> The display names assigned to tokens, or {@code null}
|
||||||
|
/// to use the values in {@code literalNames} and {@code symbolicNames} as
|
||||||
|
/// the source of display names, as described in
|
||||||
|
/// <seealso cref="#getDisplayName(int)"/>.
|
||||||
|
/// </param>
|
||||||
|
/// <seealso cref= #getLiteralName(int) </seealso>
|
||||||
|
/// <seealso cref= #getSymbolicName(int) </seealso>
|
||||||
|
/// <seealso cref= #getDisplayName(int) </seealso>
|
||||||
|
VocabularyImpl(const std::vector<std::wstring> &literalNames, const std::vector<std::wstring> &symbolicNames,
|
||||||
|
const std::vector<std::wstring> &displayNames);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a <seealso cref="VocabularyImpl"/> instance from the specified set of token
|
||||||
|
/// names. This method acts as a compatibility layer for the single
|
||||||
|
/// {@code tokenNames} array generated by previous releases of ANTLR.
|
||||||
|
///
|
||||||
|
/// <para>The resulting vocabulary instance returns {@code null} for
|
||||||
|
/// <seealso cref="#getLiteralName(int)"/> and <seealso cref="#getSymbolicName(int)"/>, and the
|
||||||
|
/// value from {@code tokenNames} for the display names.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tokenNames"> The token names, or {@code null} if no token names are
|
||||||
|
/// available. </param>
|
||||||
|
/// <returns> A <seealso cref="Vocabulary"/> instance which uses {@code tokenNames} for
|
||||||
|
/// the display names of tokens. </returns>
|
||||||
|
static Ref<Vocabulary> fromTokenNames(const std::vector<std::wstring> &tokenNames);
|
||||||
|
|
||||||
|
virtual int getMaxTokenType() const override;
|
||||||
|
virtual std::wstring getLiteralName(ssize_t tokenType) const override;
|
||||||
|
virtual std::wstring getSymbolicName(ssize_t tokenType) const override;
|
||||||
|
virtual std::wstring getDisplayName(ssize_t tokenType) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::vector<std::wstring> const EMPTY_NAMES;
|
||||||
|
|
||||||
|
std::vector<std::wstring> const _literalNames;
|
||||||
|
std::vector<std::wstring> const _symbolicNames;
|
||||||
|
std::vector<std::wstring> const _displayNames;
|
||||||
|
const int _maxTokenType;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -40,18 +40,11 @@ namespace runtime {
|
||||||
|
|
||||||
class WritableToken : public Token {
|
class WritableToken : public Token {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<WritableToken> Ref;
|
|
||||||
|
|
||||||
virtual void setText(const std::wstring &text) = 0;
|
virtual void setText(const std::wstring &text) = 0;
|
||||||
|
|
||||||
virtual void setType(int ttype) = 0;
|
virtual void setType(int ttype) = 0;
|
||||||
|
|
||||||
virtual void setLine(int line) = 0;
|
virtual void setLine(int line) = 0;
|
||||||
|
|
||||||
virtual void setCharPositionInLine(int pos) = 0;
|
virtual void setCharPositionInLine(int pos) = 0;
|
||||||
|
|
||||||
virtual void setChannel(int channel) = 0;
|
virtual void setChannel(int channel) = 0;
|
||||||
|
|
||||||
virtual void setTokenIndex(int index) = 0;
|
virtual void setTokenIndex(int index) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -98,3 +98,6 @@
|
||||||
#define NOEXCEPT
|
#define NOEXCEPT
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<class T> using Ref = std::shared_ptr<T>;
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ ATN& ATN::operator = (ATN &&other) NOEXCEPT {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
misc::IntervalSet ATN::nextTokens(ATNState *s, RuleContext::Ref ctx) const {
|
misc::IntervalSet ATN::nextTokens(ATNState *s, Ref<RuleContext> ctx) const {
|
||||||
LL1Analyzer analyzer(*this);
|
LL1Analyzer analyzer(*this);
|
||||||
return analyzer.LOOK(s, ctx);
|
return analyzer.LOOK(s, ctx);
|
||||||
|
|
||||||
|
@ -150,12 +150,12 @@ int ATN::getNumberOfDecisions() const {
|
||||||
return (int)decisionToState.size();
|
return (int)decisionToState.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
misc::IntervalSet ATN::getExpectedTokens(int stateNumber, RuleContext::Ref context) const {
|
misc::IntervalSet ATN::getExpectedTokens(int stateNumber, Ref<RuleContext> context) const {
|
||||||
if (stateNumber < 0 || stateNumber >= (int)states.size()) {
|
if (stateNumber < 0 || stateNumber >= (int)states.size()) {
|
||||||
throw IllegalArgumentException("Invalid state number.");
|
throw IllegalArgumentException("Invalid state number.");
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleContext::Ref ctx = context;
|
Ref<RuleContext> ctx = context;
|
||||||
ATNState *s = states.at((size_t)stateNumber);
|
ATNState *s = states.at((size_t)stateNumber);
|
||||||
misc::IntervalSet following = nextTokens(s);
|
misc::IntervalSet following = nextTokens(s);
|
||||||
if (!following.contains(Token::EPSILON)) {
|
if (!following.contains(Token::EPSILON)) {
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "RuleContext.h"
|
#include "RuleContext.h"
|
||||||
#include "LexerAction.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -80,7 +79,7 @@ namespace atn {
|
||||||
|
|
||||||
/// For lexer ATNs, this is an array of {@link LexerAction} objects which may
|
/// For lexer ATNs, this is an array of {@link LexerAction} objects which may
|
||||||
/// be referenced by action transitions in the ATN.
|
/// be referenced by action transitions in the ATN.
|
||||||
std::vector<LexerAction::Ref> lexerActions;
|
std::vector<Ref<LexerAction>> lexerActions;
|
||||||
|
|
||||||
std::vector<TokensStartState*> modeToStartState;
|
std::vector<TokensStartState*> modeToStartState;
|
||||||
|
|
||||||
|
@ -93,7 +92,7 @@ namespace atn {
|
||||||
/// the rule surrounding {@code s}. In other words, the set will be
|
/// the rule surrounding {@code s}. In other words, the set will be
|
||||||
/// restricted to tokens reachable staying within {@code s}'s rule.
|
/// restricted to tokens reachable staying within {@code s}'s rule.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual misc::IntervalSet nextTokens(ATNState *s, RuleContext::Ref ctx) const;
|
virtual misc::IntervalSet nextTokens(ATNState *s, Ref<RuleContext> ctx) const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compute the set of valid tokens that can occur starting in {@code s} and
|
/// Compute the set of valid tokens that can occur starting in {@code s} and
|
||||||
|
@ -130,7 +129,7 @@ namespace atn {
|
||||||
/// specified state in the specified context. </returns>
|
/// specified state in the specified context. </returns>
|
||||||
/// <exception cref="IllegalArgumentException"> if the ATN does not contain a state with
|
/// <exception cref="IllegalArgumentException"> if the ATN does not contain a state with
|
||||||
/// number {@code stateNumber} </exception>
|
/// number {@code stateNumber} </exception>
|
||||||
virtual misc::IntervalSet getExpectedTokens(int stateNumber, RuleContext::Ref context) const;
|
virtual misc::IntervalSet getExpectedTokens(int stateNumber, Ref<RuleContext> context) const;
|
||||||
|
|
||||||
std::wstring toString() const;
|
std::wstring toString() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "MurmurHash.h"
|
#include "MurmurHash.h"
|
||||||
#include "PredictionContext.h"
|
#include "PredictionContext.h"
|
||||||
|
#include "SemanticContext.h"
|
||||||
|
|
||||||
#include "ATNConfig.h"
|
#include "ATNConfig.h"
|
||||||
|
|
||||||
|
@ -38,34 +39,34 @@ using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
const size_t ATNConfig::SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
|
const size_t ATNConfig::SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNState *state, int alt, PredictionContext::Ref context)
|
ATNConfig::ATNConfig(ATNState *state, int alt, Ref<PredictionContext> context)
|
||||||
: ATNConfig(state, alt, context, SemanticContext::NONE) {
|
: ATNConfig(state, alt, context, SemanticContext::NONE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNState *state, int alt, PredictionContext::Ref context, SemanticContext::Ref semanticContext)
|
ATNConfig::ATNConfig(ATNState *state, int alt, Ref<PredictionContext> context, Ref<SemanticContext> semanticContext)
|
||||||
: state(state), alt(alt), context(context), semanticContext(semanticContext) {
|
: state(state), alt(alt), context(context), semanticContext(semanticContext) {
|
||||||
reachesIntoOuterContext = 0;
|
reachesIntoOuterContext = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNConfig::Ref c) : ATNConfig(c, c->state, c->context, c->semanticContext) {
|
ATNConfig::ATNConfig(Ref<ATNConfig> c) : ATNConfig(c, c->state, c->context, c->semanticContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNConfig::Ref c, ATNState *state) : ATNConfig(c, state, c->context, c->semanticContext) {
|
ATNConfig::ATNConfig(Ref<ATNConfig> c, ATNState *state) : ATNConfig(c, state, c->context, c->semanticContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNConfig::Ref c, ATNState *state, SemanticContext::Ref semanticContext)
|
ATNConfig::ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<SemanticContext> semanticContext)
|
||||||
: ATNConfig(c, state, c->context, semanticContext) {
|
: ATNConfig(c, state, c->context, semanticContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNConfig::Ref c, SemanticContext::Ref semanticContext)
|
ATNConfig::ATNConfig(Ref<ATNConfig> c, Ref<SemanticContext> semanticContext)
|
||||||
: ATNConfig(c, c->state, c->context, semanticContext) {
|
: ATNConfig(c, c->state, c->context, semanticContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNConfig::Ref c, ATNState *state, PredictionContext::Ref context)
|
ATNConfig::ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<PredictionContext> context)
|
||||||
: ATNConfig(c, state, context, c->semanticContext) {
|
: ATNConfig(c, state, context, c->semanticContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::ATNConfig(ATNConfig::Ref c, ATNState *state, PredictionContext::Ref context, SemanticContext::Ref semanticContext)
|
ATNConfig::ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<PredictionContext> context, Ref<SemanticContext> semanticContext)
|
||||||
: state(state), alt(c->alt), context(context), semanticContext(semanticContext), reachesIntoOuterContext(c->reachesIntoOuterContext) {
|
: state(state), alt(c->alt), context(context), semanticContext(semanticContext), reachesIntoOuterContext(c->reachesIntoOuterContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "PredictionContext.h"
|
|
||||||
#include "SemanticContext.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
namespace v4 {
|
namespace v4 {
|
||||||
|
@ -50,8 +47,6 @@ namespace atn {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ATNConfig {
|
class ATNConfig {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<ATNConfig> Ref;
|
|
||||||
|
|
||||||
/// The ATN state associated with this configuration.
|
/// The ATN state associated with this configuration.
|
||||||
ATNState * state;
|
ATNState * state;
|
||||||
|
|
||||||
|
@ -64,7 +59,7 @@ namespace atn {
|
||||||
/// execution of the ATN simulator.
|
/// execution of the ATN simulator.
|
||||||
///
|
///
|
||||||
/// Can be shared between multiple ANTConfig instances.
|
/// Can be shared between multiple ANTConfig instances.
|
||||||
PredictionContext::Ref context;
|
Ref<PredictionContext> context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We cannot execute predicates dependent upon local context unless
|
* We cannot execute predicates dependent upon local context unless
|
||||||
|
@ -92,17 +87,17 @@ namespace atn {
|
||||||
int reachesIntoOuterContext;
|
int reachesIntoOuterContext;
|
||||||
|
|
||||||
/// Can be shared between multiple ATNConfig instances.
|
/// Can be shared between multiple ATNConfig instances.
|
||||||
SemanticContext::Ref semanticContext;
|
Ref<SemanticContext> semanticContext;
|
||||||
|
|
||||||
ATNConfig(ATNState *state, int alt, PredictionContext::Ref context);
|
ATNConfig(ATNState *state, int alt, Ref<PredictionContext> context);
|
||||||
ATNConfig(ATNState *state, int alt, PredictionContext::Ref context, SemanticContext::Ref semanticContext);
|
ATNConfig(ATNState *state, int alt, Ref<PredictionContext> context, Ref<SemanticContext> semanticContext);
|
||||||
|
|
||||||
ATNConfig(ATNConfig::Ref c); // dup
|
ATNConfig(Ref<ATNConfig> c); // dup
|
||||||
ATNConfig(ATNConfig::Ref c, ATNState *state);
|
ATNConfig(Ref<ATNConfig> c, ATNState *state);
|
||||||
ATNConfig(ATNConfig::Ref c, ATNState *state, SemanticContext::Ref semanticContext);
|
ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<SemanticContext> semanticContext);
|
||||||
ATNConfig(ATNConfig::Ref c, SemanticContext::Ref semanticContext);
|
ATNConfig(Ref<ATNConfig> c, Ref<SemanticContext> semanticContext);
|
||||||
ATNConfig(ATNConfig::Ref c, ATNState *state, PredictionContext::Ref context);
|
ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<PredictionContext> context);
|
||||||
ATNConfig(ATNConfig::Ref c, ATNState *state, PredictionContext::Ref context, SemanticContext::Ref semanticContext);
|
ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<PredictionContext> context, Ref<SemanticContext> semanticContext);
|
||||||
|
|
||||||
virtual size_t hashCode() const;
|
virtual size_t hashCode() const;
|
||||||
|
|
||||||
|
@ -165,4 +160,16 @@ namespace std {
|
||||||
return x.hashCode();
|
return x.hashCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <> struct hash<std::vector<Ref<ATNConfig>>>
|
||||||
|
{
|
||||||
|
size_t operator() (const std::vector<Ref<ATNConfig>> &vector) const
|
||||||
|
{
|
||||||
|
std::size_t seed = 0;
|
||||||
|
for (auto &config : vector) {
|
||||||
|
seed ^= config->hashCode() + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||||
|
}
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,14 @@
|
||||||
#include "ATNConfig.h"
|
#include "ATNConfig.h"
|
||||||
#include "ATNSimulator.h"
|
#include "ATNSimulator.h"
|
||||||
#include "Exceptions.h"
|
#include "Exceptions.h"
|
||||||
|
#include "SemanticContext.h"
|
||||||
|
|
||||||
#include "ATNConfigSet.h"
|
#include "ATNConfigSet.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime::atn;
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
using namespace antlrcpp;
|
using namespace antlrcpp;
|
||||||
|
|
||||||
size_t SimpleATNConfigHasher::operator()(const ATNConfig::Ref &k) const {
|
size_t SimpleATNConfigHasher::operator()(const Ref<ATNConfig> &k) const {
|
||||||
size_t hashCode = 7;
|
size_t hashCode = 7;
|
||||||
hashCode = 31 * hashCode + (size_t)k->state->stateNumber;
|
hashCode = 31 * hashCode + (size_t)k->state->stateNumber;
|
||||||
hashCode = 31 * hashCode + (size_t)k->alt;
|
hashCode = 31 * hashCode + (size_t)k->alt;
|
||||||
|
@ -47,7 +48,7 @@ size_t SimpleATNConfigHasher::operator()(const ATNConfig::Ref &k) const {
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleATNConfigComparer::operator () (const ATNConfig::Ref &lhs, const ATNConfig::Ref &rhs) const {
|
bool SimpleATNConfigComparer::operator () (const Ref<ATNConfig> &lhs, const Ref<ATNConfig> &rhs) const {
|
||||||
return lhs->state->stateNumber == rhs->state->stateNumber && lhs->alt == rhs->alt &&
|
return lhs->state->stateNumber == rhs->state->stateNumber && lhs->alt == rhs->alt &&
|
||||||
lhs->semanticContext == rhs->semanticContext;
|
lhs->semanticContext == rhs->semanticContext;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +59,7 @@ ATNConfigSet::ATNConfigSet(bool fullCtx) : fullCtx(fullCtx) {
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfigSet::ATNConfigSet(std::shared_ptr<ATNConfigSet> old) : ATNConfigSet(old->fullCtx) {
|
ATNConfigSet::ATNConfigSet(Ref<ATNConfigSet> old) : ATNConfigSet(old->fullCtx) {
|
||||||
addAll(old);
|
addAll(old);
|
||||||
uniqueAlt = old->uniqueAlt;
|
uniqueAlt = old->uniqueAlt;
|
||||||
conflictingAlts = old->conflictingAlts;
|
conflictingAlts = old->conflictingAlts;
|
||||||
|
@ -69,11 +70,11 @@ ATNConfigSet::ATNConfigSet(std::shared_ptr<ATNConfigSet> old) : ATNConfigSet(old
|
||||||
ATNConfigSet::~ATNConfigSet() {
|
ATNConfigSet::~ATNConfigSet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ATNConfigSet::add(ATNConfig::Ref config) {
|
bool ATNConfigSet::add(Ref<ATNConfig> config) {
|
||||||
return add(config, nullptr);
|
return add(config, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ATNConfigSet::add(ATNConfig::Ref config, PredictionContextMergeCache *mergeCache) {
|
bool ATNConfigSet::add(Ref<ATNConfig> config, PredictionContextMergeCache *mergeCache) {
|
||||||
if (_readonly) {
|
if (_readonly) {
|
||||||
throw IllegalStateException("This set is readonly");
|
throw IllegalStateException("This set is readonly");
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,7 @@ bool ATNConfigSet::add(ATNConfig::Ref config, PredictionContextMergeCache *merge
|
||||||
dipsIntoOuterContext = true;
|
dipsIntoOuterContext = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::Ref existing = configLookup->getOrAdd(config);
|
Ref<ATNConfig> existing = configLookup->getOrAdd(config);
|
||||||
if (existing == config) { // we added this new one
|
if (existing == config) { // we added this new one
|
||||||
_cachedHashCode = 0;
|
_cachedHashCode = 0;
|
||||||
configs.push_back(config); // track order here
|
configs.push_back(config); // track order here
|
||||||
|
@ -93,7 +94,7 @@ bool ATNConfigSet::add(ATNConfig::Ref config, PredictionContextMergeCache *merge
|
||||||
}
|
}
|
||||||
// a previous (s,i,pi,_), merge with it and save result
|
// a previous (s,i,pi,_), merge with it and save result
|
||||||
bool rootIsWildcard = !fullCtx;
|
bool rootIsWildcard = !fullCtx;
|
||||||
PredictionContext::Ref merged = PredictionContext::merge(existing->context, config->context, rootIsWildcard, mergeCache);
|
Ref<PredictionContext> merged = PredictionContext::merge(existing->context, config->context, rootIsWildcard, mergeCache);
|
||||||
// no need to check for existing.context, config.context in cache
|
// no need to check for existing.context, config.context in cache
|
||||||
// since only way to create new graphs is "call rule" and here. We
|
// since only way to create new graphs is "call rule" and here. We
|
||||||
// cache at both places.
|
// cache at both places.
|
||||||
|
@ -108,14 +109,14 @@ bool ATNConfigSet::add(ATNConfig::Ref config, PredictionContextMergeCache *merge
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ATNConfigSet::addAll(std::shared_ptr<ATNConfigSet> other) {
|
bool ATNConfigSet::addAll(Ref<ATNConfigSet> other) {
|
||||||
for (auto &c : other->configs) {
|
for (auto &c : other->configs) {
|
||||||
add(c);
|
add(c);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ATNConfig::Ref> ATNConfigSet::elements() {
|
std::vector<Ref<ATNConfig>> ATNConfigSet::elements() {
|
||||||
return configs;
|
return configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,8 +145,8 @@ BitSet ATNConfigSet::getAlts() {
|
||||||
return alts;
|
return alts;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SemanticContext::Ref> ATNConfigSet::getPredicates() {
|
std::vector<Ref<SemanticContext>> ATNConfigSet::getPredicates() {
|
||||||
std::vector<SemanticContext::Ref> preds;
|
std::vector<Ref<SemanticContext>> preds;
|
||||||
for (auto c : configs) {
|
for (auto c : configs) {
|
||||||
if (c->semanticContext != SemanticContext::NONE) {
|
if (c->semanticContext != SemanticContext::NONE) {
|
||||||
preds.push_back(c->semanticContext);
|
preds.push_back(c->semanticContext);
|
||||||
|
@ -154,7 +155,7 @@ std::vector<SemanticContext::Ref> ATNConfigSet::getPredicates() {
|
||||||
return preds;
|
return preds;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::Ref ATNConfigSet::get(size_t i) const {
|
Ref<ATNConfig> ATNConfigSet::get(size_t i) const {
|
||||||
return configs[i];
|
return configs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,13 +203,13 @@ bool ATNConfigSet::operator == (const ATNConfigSet &other) {
|
||||||
size_t ATNConfigSet::hashCode() {
|
size_t ATNConfigSet::hashCode() {
|
||||||
if (isReadonly()) {
|
if (isReadonly()) {
|
||||||
if (_cachedHashCode == 0) {
|
if (_cachedHashCode == 0) {
|
||||||
_cachedHashCode = std::hash<std::vector<ATNConfig::Ref>>()(configs);
|
_cachedHashCode = std::hash<std::vector<Ref<ATNConfig>>>()(configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cachedHashCode;
|
return _cachedHashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::hash<std::vector<ATNConfig::Ref>>()(configs);
|
return std::hash<std::vector<Ref<ATNConfig>>>()(configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ATNConfigSet::size() {
|
size_t ATNConfigSet::size() {
|
||||||
|
@ -219,7 +220,7 @@ bool ATNConfigSet::isEmpty() {
|
||||||
return configs.empty();
|
return configs.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ATNConfigSet::contains(ATNConfig::Ref o) {
|
bool ATNConfigSet::contains(Ref<ATNConfig> o) {
|
||||||
if (configLookup == nullptr) {
|
if (configLookup == nullptr) {
|
||||||
throw UnsupportedOperationException("This method is not implemented for readonly sets.");
|
throw UnsupportedOperationException("This method is not implemented for readonly sets.");
|
||||||
}
|
}
|
||||||
|
@ -276,7 +277,7 @@ bool ATNConfigSet::remove(void *o) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATNConfigSet::InitializeInstanceFields() {
|
void ATNConfigSet::InitializeInstanceFields() {
|
||||||
configLookup = std::shared_ptr<ConfigLookup>(new ConfigLookupImpl<SimpleATNConfigHasher, SimpleATNConfigComparer>());
|
configLookup = Ref<ConfigLookup>(new ConfigLookupImpl<SimpleATNConfigHasher, SimpleATNConfigComparer>());
|
||||||
uniqueAlt = 0;
|
uniqueAlt = 0;
|
||||||
hasSemanticContext = false;
|
hasSemanticContext = false;
|
||||||
dipsIntoOuterContext = false;
|
dipsIntoOuterContext = false;
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BitSet.h"
|
#include "BitSet.h"
|
||||||
#include "ATNConfig.h"
|
|
||||||
#include "ConfigLookup.h"
|
#include "ConfigLookup.h"
|
||||||
|
#include "PredictionContext.h"
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -44,11 +44,11 @@ namespace atn {
|
||||||
// Simpler hasher and comparer variants than those in ATNConfig (less fields, no murmur hash).
|
// Simpler hasher and comparer variants than those in ATNConfig (less fields, no murmur hash).
|
||||||
struct SimpleATNConfigHasher
|
struct SimpleATNConfigHasher
|
||||||
{
|
{
|
||||||
size_t operator()(const ATNConfig::Ref &k) const;
|
size_t operator()(const Ref<ATNConfig> &k) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SimpleATNConfigComparer {
|
struct SimpleATNConfigComparer {
|
||||||
bool operator()(const ATNConfig::Ref &lhs, const ATNConfig::Ref &rhs) const;
|
bool operator()(const Ref<ATNConfig> &lhs, const Ref<ATNConfig> &rhs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialized set that can track info about the set, with support for combining similar configurations using a
|
/// Specialized set that can track info about the set, with support for combining similar configurations using a
|
||||||
|
@ -57,11 +57,11 @@ namespace atn {
|
||||||
public:
|
public:
|
||||||
/// All configs but hashed by (s, i, _, pi) not including context. Wiped out
|
/// All configs but hashed by (s, i, _, pi) not including context. Wiped out
|
||||||
/// when we go readonly as this set becomes a DFA state.
|
/// when we go readonly as this set becomes a DFA state.
|
||||||
std::shared_ptr<ConfigLookup> configLookup;
|
Ref<ConfigLookup> configLookup;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Track the elements as they are added to the set; supports get(i) </summary>
|
/// Track the elements as they are added to the set; supports get(i) </summary>
|
||||||
std::vector<ATNConfig::Ref> configs;
|
std::vector<Ref<ATNConfig>> configs;
|
||||||
|
|
||||||
// TO_DO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
|
// TO_DO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
|
||||||
// TO_DO: can we track conflicts as they are added to save scanning configs later?
|
// TO_DO: can we track conflicts as they are added to save scanning configs later?
|
||||||
|
@ -87,11 +87,11 @@ namespace atn {
|
||||||
const bool fullCtx;
|
const bool fullCtx;
|
||||||
|
|
||||||
ATNConfigSet(bool fullCtx = true);
|
ATNConfigSet(bool fullCtx = true);
|
||||||
ATNConfigSet(std::shared_ptr<ATNConfigSet> old);
|
ATNConfigSet(Ref<ATNConfigSet> old);
|
||||||
|
|
||||||
virtual ~ATNConfigSet();
|
virtual ~ATNConfigSet();
|
||||||
|
|
||||||
virtual bool add(ATNConfig::Ref config);
|
virtual bool add(Ref<ATNConfig> config);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adding a new config means merging contexts with existing configs for
|
/// Adding a new config means merging contexts with existing configs for
|
||||||
|
@ -103,11 +103,11 @@ namespace atn {
|
||||||
/// This method updates <seealso cref="#dipsIntoOuterContext"/> and
|
/// This method updates <seealso cref="#dipsIntoOuterContext"/> and
|
||||||
/// <seealso cref="#hasSemanticContext"/> when necessary.
|
/// <seealso cref="#hasSemanticContext"/> when necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual bool add(ATNConfig::Ref config, PredictionContextMergeCache *mergeCache);
|
virtual bool add(Ref<ATNConfig> config, PredictionContextMergeCache *mergeCache);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return a List holding list of configs </summary>
|
/// Return a List holding list of configs </summary>
|
||||||
virtual std::vector<ATNConfig::Ref> elements();
|
virtual std::vector<Ref<ATNConfig>> elements();
|
||||||
|
|
||||||
virtual std::vector<ATNState *> getStates();
|
virtual std::vector<ATNState *> getStates();
|
||||||
|
|
||||||
|
@ -120,19 +120,19 @@ namespace atn {
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
antlrcpp::BitSet getAlts();
|
antlrcpp::BitSet getAlts();
|
||||||
virtual std::vector<SemanticContext::Ref> getPredicates();
|
virtual std::vector<Ref<SemanticContext>> getPredicates();
|
||||||
|
|
||||||
virtual ATNConfig::Ref get(size_t i) const;
|
virtual Ref<ATNConfig> get(size_t i) const;
|
||||||
|
|
||||||
virtual void optimizeConfigs(ATNSimulator *interpreter);
|
virtual void optimizeConfigs(ATNSimulator *interpreter);
|
||||||
|
|
||||||
bool addAll(std::shared_ptr<ATNConfigSet> other);
|
bool addAll(Ref<ATNConfigSet> other);
|
||||||
|
|
||||||
bool operator == (const ATNConfigSet &other);
|
bool operator == (const ATNConfigSet &other);
|
||||||
virtual size_t hashCode();
|
virtual size_t hashCode();
|
||||||
virtual size_t size();
|
virtual size_t size();
|
||||||
virtual bool isEmpty();
|
virtual bool isEmpty();
|
||||||
virtual bool contains(ATNConfig::Ref o);
|
virtual bool contains(Ref<ATNConfig> o);
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
virtual bool isReadonly();
|
virtual bool isReadonly();
|
||||||
virtual void setReadonly(bool readonly);
|
virtual void setReadonly(bool readonly);
|
||||||
|
@ -158,17 +158,3 @@ namespace atn {
|
||||||
} // namespace v4
|
} // namespace v4
|
||||||
} // namespace antlr
|
} // namespace antlr
|
||||||
} // namespace org
|
} // namespace org
|
||||||
|
|
||||||
namespace std {
|
|
||||||
template <> struct hash<std::vector<ATNConfig::Ref>>
|
|
||||||
{
|
|
||||||
size_t operator() (const std::vector<ATNConfig::Ref > &vector) const
|
|
||||||
{
|
|
||||||
std::size_t seed = 0;
|
|
||||||
for (auto &config : vector) {
|
|
||||||
seed ^= config->hashCode() + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
|
||||||
}
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -407,7 +407,7 @@ ATN ATNDeserializer::deserialize(const std::wstring& input) {
|
||||||
|
|
||||||
int ruleIndex = static_cast<ActionTransition *>(transition)->ruleIndex;
|
int ruleIndex = static_cast<ActionTransition *>(transition)->ruleIndex;
|
||||||
int actionIndex = static_cast<ActionTransition *>(transition)->actionIndex;
|
int actionIndex = static_cast<ActionTransition *>(transition)->actionIndex;
|
||||||
std::shared_ptr<LexerCustomAction> lexerAction = std::make_shared<LexerCustomAction>(ruleIndex, actionIndex);
|
Ref<LexerCustomAction> lexerAction = std::make_shared<LexerCustomAction>(ruleIndex, actionIndex);
|
||||||
state->setTransition(i, new ActionTransition(transition->target, ruleIndex, (int)atn.lexerActions.size(), false)); /* mem-check freed in ATNState d-tor */
|
state->setTransition(i, new ActionTransition(transition->target, ruleIndex, (int)atn.lexerActions.size(), false)); /* mem-check freed in ATNState d-tor */
|
||||||
atn.lexerActions.push_back(lexerAction);
|
atn.lexerActions.push_back(lexerAction);
|
||||||
}
|
}
|
||||||
|
@ -706,7 +706,7 @@ ATNState* ATNDeserializer::stateFactory(int type, int ruleIndex) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerAction::Ref ATNDeserializer::lexerActionFactory(LexerActionType type, int data1, int data2) {
|
Ref<LexerAction> ATNDeserializer::lexerActionFactory(LexerActionType type, int data1, int data2) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LexerActionType::CHANNEL:
|
case LexerActionType::CHANNEL:
|
||||||
return std::make_shared<LexerChannelAction>(data1);
|
return std::make_shared<LexerChannelAction>(data1);
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace atn {
|
||||||
/// introduced; otherwise, {@code false}. </returns>
|
/// introduced; otherwise, {@code false}. </returns>
|
||||||
virtual bool isFeatureSupported(const Guid &feature, const Guid &actualUuid);
|
virtual bool isFeatureSupported(const Guid &feature, const Guid &actualUuid);
|
||||||
void markPrecedenceDecisions(const ATN &atn);
|
void markPrecedenceDecisions(const ATN &atn);
|
||||||
LexerAction::Ref lexerActionFactory(LexerActionType type, int data1, int data2);
|
Ref<LexerAction> lexerActionFactory(LexerActionType type, int data1, int data2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// This is the earliest supported serialized UUID.
|
/// This is the earliest supported serialized UUID.
|
||||||
|
|
|
@ -310,7 +310,7 @@ std::vector<size_t> ATNSerializer::serialize() {
|
||||||
// LEXER ACTIONS
|
// LEXER ACTIONS
|
||||||
if (atn->grammarType == ATNType::LEXER) {
|
if (atn->grammarType == ATNType::LEXER) {
|
||||||
data.push_back(atn->lexerActions.size());
|
data.push_back(atn->lexerActions.size());
|
||||||
for (LexerAction::Ref action : atn->lexerActions) {
|
for (Ref<LexerAction> action : atn->lexerActions) {
|
||||||
data.push_back((size_t)action->getActionType());
|
data.push_back((size_t)action->getActionType());
|
||||||
switch (action->getActionType()) {
|
switch (action->getActionType()) {
|
||||||
case LexerActionType::CHANNEL:
|
case LexerActionType::CHANNEL:
|
||||||
|
|
|
@ -41,19 +41,23 @@ using namespace org::antlr::v4::runtime;
|
||||||
using namespace org::antlr::v4::runtime::dfa;
|
using namespace org::antlr::v4::runtime::dfa;
|
||||||
using namespace org::antlr::v4::runtime::atn;
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
const std::shared_ptr<DFAState> ATNSimulator::ERROR = std::make_shared<DFAState>(INT32_MAX);
|
const Ref<DFAState> ATNSimulator::ERROR = std::make_shared<DFAState>(INT32_MAX);
|
||||||
|
|
||||||
ATNSimulator::ATNSimulator(const ATN &atn, std::shared_ptr<PredictionContextCache> sharedContextCache)
|
ATNSimulator::ATNSimulator(const ATN &atn, Ref<PredictionContextCache> sharedContextCache)
|
||||||
: atn(atn), _sharedContextCache(sharedContextCache) {
|
: atn(atn), _sharedContextCache(sharedContextCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<PredictionContextCache> ATNSimulator::getSharedContextCache() {
|
void ATNSimulator::clearDFA() {
|
||||||
|
throw UnsupportedOperationException("This ATN simulator does not support clearing the DFA.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<PredictionContextCache> ATNSimulator::getSharedContextCache() {
|
||||||
return _sharedContextCache;
|
return _sharedContextCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
PredictionContext::Ref ATNSimulator::getCachedContext(PredictionContext::Ref context) {
|
Ref<PredictionContext> ATNSimulator::getCachedContext(Ref<PredictionContext> context) {
|
||||||
std::lock_guard<std::mutex> lck(mtx);
|
std::lock_guard<std::mutex> lck(mtx);
|
||||||
std::map<PredictionContext::Ref, PredictionContext::Ref> visited;
|
std::map<Ref<PredictionContext>, Ref<PredictionContext>> visited;
|
||||||
return PredictionContext::getCachedContext(context, _sharedContextCache, visited);
|
return PredictionContext::getCachedContext(context, _sharedContextCache, visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,18 +43,29 @@ namespace atn {
|
||||||
|
|
||||||
class ATNSimulator {
|
class ATNSimulator {
|
||||||
public:
|
public:
|
||||||
virtual ~ATNSimulator() {};
|
|
||||||
|
|
||||||
/// Must distinguish between missing edge and edge we know leads nowhere.
|
/// Must distinguish between missing edge and edge we know leads nowhere.
|
||||||
static const std::shared_ptr<dfa::DFAState> ERROR;
|
static const Ref<dfa::DFAState> ERROR;
|
||||||
const ATN &atn;
|
const ATN &atn;
|
||||||
|
|
||||||
ATNSimulator(const ATN &atn, std::shared_ptr<PredictionContextCache> sharedContextCache);
|
ATNSimulator(const ATN &atn, Ref<PredictionContextCache> sharedContextCache);
|
||||||
|
virtual ~ATNSimulator() {};
|
||||||
|
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<PredictionContextCache> getSharedContextCache();
|
/**
|
||||||
virtual PredictionContext::Ref getCachedContext(PredictionContext::Ref context);
|
* Clear the DFA cache used by the current instance. Since the DFA cache may
|
||||||
|
* be shared by multiple ATN simulators, this method may affect the
|
||||||
|
* performance (but not accuracy) of other parsers which are being used
|
||||||
|
* concurrently.
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException if the current instance does not
|
||||||
|
* support clearing the DFA.
|
||||||
|
*
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
virtual void clearDFA();
|
||||||
|
virtual Ref<PredictionContextCache> getSharedContextCache();
|
||||||
|
virtual Ref<PredictionContext> getCachedContext(Ref<PredictionContext> context);
|
||||||
|
|
||||||
/// @deprecated Use <seealso cref="ATNDeserializer#deserialize"/> instead.
|
/// @deprecated Use <seealso cref="ATNDeserializer#deserialize"/> instead.
|
||||||
static ATN deserialize(const std::wstring &data);
|
static ATN deserialize(const std::wstring &data);
|
||||||
|
@ -97,7 +108,7 @@ namespace atn {
|
||||||
/// more time I think and doesn't save on the overall footprint
|
/// more time I think and doesn't save on the overall footprint
|
||||||
/// so it's not worth the complexity.
|
/// so it's not worth the complexity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
std::shared_ptr<PredictionContextCache> _sharedContextCache;
|
Ref<PredictionContextCache> _sharedContextCache;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AmbiguityInfo.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime;
|
||||||
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
|
AmbiguityInfo::AmbiguityInfo(int decision, Ref<ATNConfigSet> configs, const antlrcpp::BitSet &ambigAlts,
|
||||||
|
TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx)
|
||||||
|
: DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) {
|
||||||
|
|
||||||
|
this->ambigAlts = ambigAlts;
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "DecisionEventInfo.h"
|
||||||
|
#include "BitSet.h"
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace atn {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents profiling event information for an ambiguity.
|
||||||
|
/// Ambiguities are decisions where a particular input resulted in an SLL
|
||||||
|
/// conflict, followed by LL prediction also reaching a conflict state
|
||||||
|
/// (indicating a true ambiguity in the grammar).
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// This event may be reported during SLL prediction in cases where the
|
||||||
|
/// conflicting SLL configuration set provides sufficient information to
|
||||||
|
/// determine that the SLL conflict is truly an ambiguity. For example, if none
|
||||||
|
/// of the ATN configurations in the conflicting SLL configuration set have
|
||||||
|
/// traversed a global follow transition (i.e.
|
||||||
|
/// <seealso cref="ATNConfig#reachesIntoOuterContext"/> is 0 for all configurations), then
|
||||||
|
/// the result of SLL prediction for that input is known to be equivalent to the
|
||||||
|
/// result of LL prediction for that input.</para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// In some cases, the minimum represented alternative in the conflicting LL
|
||||||
|
/// configuration set is not equal to the minimum represented alternative in the
|
||||||
|
/// conflicting SLL configuration set. Grammars and inputs which result in this
|
||||||
|
/// scenario are unable to use <seealso cref="PredictionMode#SLL"/>, which in turn means
|
||||||
|
/// they cannot use the two-stage parsing strategy to improve parsing performance
|
||||||
|
/// for that input.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= ParserATNSimulator#reportAmbiguity </seealso>
|
||||||
|
/// <seealso cref= ANTLRErrorListener#reportAmbiguity
|
||||||
|
///
|
||||||
|
/// @since 4.3 </seealso>
|
||||||
|
class AmbiguityInfo : public DecisionEventInfo {
|
||||||
|
public:
|
||||||
|
/// The set of alternative numbers for this decision event that lead to a valid parse.
|
||||||
|
antlrcpp::BitSet ambigAlts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance of the <seealso cref="AmbiguityInfo"/> class with the
|
||||||
|
/// specified detailed ambiguity information.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="decision"> The decision number </param>
|
||||||
|
/// <param name="configs"> The final configuration set identifying the ambiguous
|
||||||
|
/// alternatives for the current input </param>
|
||||||
|
/// <param name="ambigAlts"> The set of alternatives in the decision that lead to a valid parse.
|
||||||
|
/// The predicted alt is the min(ambigAlts) </param>
|
||||||
|
/// <param name="input"> The input token stream </param>
|
||||||
|
/// <param name="startIndex"> The start index for the current prediction </param>
|
||||||
|
/// <param name="stopIndex"> The index at which the ambiguity was identified during
|
||||||
|
/// prediction </param>
|
||||||
|
/// <param name="fullCtx"> {@code true} if the ambiguity was identified during LL
|
||||||
|
/// prediction; otherwise, {@code false} if the ambiguity was identified
|
||||||
|
/// during SLL prediction </param>
|
||||||
|
AmbiguityInfo(int decision, Ref<ATNConfigSet> configs, const antlrcpp::BitSet &ambigAlts, TokenStream *input,
|
||||||
|
size_t startIndex, size_t stopIndex, bool fullCtx);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime::atn;
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
ArrayPredictionContext::ArrayPredictionContext(SingletonPredictionContext::Ref a)
|
ArrayPredictionContext::ArrayPredictionContext(Ref<SingletonPredictionContext> a)
|
||||||
: ArrayPredictionContext({ a->parent }, { a->returnState }) {
|
: ArrayPredictionContext({ a->parent }, { a->returnState }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace atn {
|
||||||
/// Sorted for merge, no duplicates; if present, EMPTY_RETURN_STATE is always last.
|
/// Sorted for merge, no duplicates; if present, EMPTY_RETURN_STATE is always last.
|
||||||
const std::vector<int> returnStates;
|
const std::vector<int> returnStates;
|
||||||
|
|
||||||
ArrayPredictionContext(SingletonPredictionContext::Ref a);
|
ArrayPredictionContext(Ref<SingletonPredictionContext> a);
|
||||||
ArrayPredictionContext(const std::vector<std::weak_ptr<PredictionContext>> &parents,
|
ArrayPredictionContext(const std::vector<std::weak_ptr<PredictionContext>> &parents,
|
||||||
const std::vector<int> &returnStates);
|
const std::vector<int> &returnStates);
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ATNConfig.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
namespace v4 {
|
namespace v4 {
|
||||||
|
@ -48,17 +46,17 @@ namespace atn {
|
||||||
|
|
||||||
ConfigLookupIterator& operator++ () { ++*_iterator; return *this; };
|
ConfigLookupIterator& operator++ () { ++*_iterator; return *this; };
|
||||||
bool operator != (const ConfigLookupIterator& rhs) const { return *_iterator != *rhs._iterator; };
|
bool operator != (const ConfigLookupIterator& rhs) const { return *_iterator != *rhs._iterator; };
|
||||||
ATNConfig::Ref operator * () const { return **_iterator; };
|
Ref<ATNConfig> operator * () const { return **_iterator; };
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<ConfigLookupIteratorImpl> _iterator;
|
Ref<ConfigLookupIteratorImpl> _iterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~ConfigLookup() {}
|
virtual ~ConfigLookup() {}
|
||||||
|
|
||||||
// Java iterator interface.
|
// Java iterator interface.
|
||||||
virtual ATNConfig::Ref getOrAdd(ATNConfig::Ref config) = 0;
|
virtual Ref<ATNConfig> getOrAdd(Ref<ATNConfig> config) = 0;
|
||||||
virtual bool isEmpty() const = 0;
|
virtual bool isEmpty() const = 0;
|
||||||
virtual bool contains(ATNConfig::Ref config) const = 0;
|
virtual bool contains(Ref<ATNConfig> config) const = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
|
||||||
// STL iterator interface.
|
// STL iterator interface.
|
||||||
|
@ -71,18 +69,18 @@ namespace atn {
|
||||||
public:
|
public:
|
||||||
virtual ConfigLookupIteratorImpl& operator ++ () = 0;
|
virtual ConfigLookupIteratorImpl& operator ++ () = 0;
|
||||||
virtual bool operator != (const ConfigLookupIteratorImpl&) const = 0;
|
virtual bool operator != (const ConfigLookupIteratorImpl&) const = 0;
|
||||||
virtual ATNConfig::Ref operator * () const = 0;
|
virtual Ref<ATNConfig> operator * () const = 0;
|
||||||
virtual void* underlyingIterator () = 0;
|
virtual void* underlyingIterator () = 0;
|
||||||
virtual const void* underlyingIterator () const = 0;
|
virtual const void* underlyingIterator () const = 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Hasher, typename Comparer>
|
template <typename Hasher, typename Comparer>
|
||||||
class ConfigLookupImpl: public ConfigLookup, std::unordered_set<ATNConfig::Ref, Hasher, Comparer> {
|
class ConfigLookupImpl: public ConfigLookup, std::unordered_set<Ref<ATNConfig>, Hasher, Comparer> {
|
||||||
public:
|
public:
|
||||||
using Set = std::unordered_set<ATNConfig::Ref, Hasher, Comparer>;
|
using Set = std::unordered_set<Ref<ATNConfig>, Hasher, Comparer>;
|
||||||
|
|
||||||
virtual ATNConfig::Ref getOrAdd(ATNConfig::Ref config) override {
|
virtual Ref<ATNConfig> getOrAdd(Ref<ATNConfig> config) override {
|
||||||
auto result = Set::find(config);
|
auto result = Set::find(config);
|
||||||
if (result != Set::end())
|
if (result != Set::end())
|
||||||
// Can potentially be a different config instance which however is considered equal to the given config
|
// Can potentially be a different config instance which however is considered equal to the given config
|
||||||
|
@ -97,7 +95,7 @@ namespace atn {
|
||||||
return Set::empty();
|
return Set::empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool contains(ATNConfig::Ref config) const override {
|
virtual bool contains(Ref<ATNConfig> config) const override {
|
||||||
return Set::count(config) > 0;
|
return Set::count(config) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,19 +110,19 @@ namespace atn {
|
||||||
ConfigLookupIterator begin() override {
|
ConfigLookupIterator begin() override {
|
||||||
return ConfigLookupIterator(
|
return ConfigLookupIterator(
|
||||||
new ConfigLookupImpl<Hasher, Comparer>::ConfigLookupIteratorImpl(
|
new ConfigLookupImpl<Hasher, Comparer>::ConfigLookupIteratorImpl(
|
||||||
std::unordered_set<ATNConfig::Ref, Hasher, Comparer>::begin())); /* mem check: managed by shared_ptr in the iterator */
|
std::unordered_set<Ref<ATNConfig>, Hasher, Comparer>::begin())); /* mem check: managed by shared_ptr in the iterator */
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigLookupIterator end() override {
|
ConfigLookupIterator end() override {
|
||||||
return ConfigLookupIterator(
|
return ConfigLookupIterator(
|
||||||
new ConfigLookupImpl<Hasher, Comparer>::ConfigLookupIteratorImpl(
|
new ConfigLookupImpl<Hasher, Comparer>::ConfigLookupIteratorImpl(
|
||||||
std::unordered_set<ATNConfig::Ref, Hasher, Comparer>::end())); /* mem check: managed by shared_ptr in the iterator */
|
std::unordered_set<Ref<ATNConfig>, Hasher, Comparer>::end())); /* mem check: managed by shared_ptr in the iterator */
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class ConfigLookupIteratorImpl : public ConfigLookup::ConfigLookupIteratorImpl {
|
class ConfigLookupIteratorImpl : public ConfigLookup::ConfigLookupIteratorImpl {
|
||||||
public:
|
public:
|
||||||
using UnderlyingIterator = typename std::unordered_set<ATNConfig::Ref, Hasher, Comparer>::iterator;
|
using UnderlyingIterator = typename std::unordered_set<Ref<ATNConfig>, Hasher, Comparer>::iterator;
|
||||||
|
|
||||||
ConfigLookupIteratorImpl(UnderlyingIterator&& iterator) : _iterator(std::move(iterator)) {
|
ConfigLookupIteratorImpl(UnderlyingIterator&& iterator) : _iterator(std::move(iterator)) {
|
||||||
}
|
}
|
||||||
|
@ -137,7 +135,7 @@ namespace atn {
|
||||||
return *reinterpret_cast<const UnderlyingIterator*>(underlyingIterator()) != *reinterpret_cast<const UnderlyingIterator*>(rhs.underlyingIterator());
|
return *reinterpret_cast<const UnderlyingIterator*>(underlyingIterator()) != *reinterpret_cast<const UnderlyingIterator*>(rhs.underlyingIterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
ATNConfig::Ref operator * () const override {
|
Ref<ATNConfig> operator * () const override {
|
||||||
return *_iterator;
|
return *_iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ContextSensitivityInfo.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime;
|
||||||
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
|
ContextSensitivityInfo::ContextSensitivityInfo(int decision, Ref<ATNConfigSet> configs, TokenStream *input,
|
||||||
|
size_t startIndex, size_t stopIndex)
|
||||||
|
: DecisionEventInfo(decision, configs, input, startIndex, stopIndex, true) {
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "DecisionEventInfo.h"
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace atn {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents profiling event information for a context sensitivity.
|
||||||
|
/// Context sensitivities are decisions where a particular input resulted in an
|
||||||
|
/// SLL conflict, but LL prediction produced a single unique alternative.
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// In some cases, the unique alternative identified by LL prediction is not
|
||||||
|
/// equal to the minimum represented alternative in the conflicting SLL
|
||||||
|
/// configuration set. Grammars and inputs which result in this scenario are
|
||||||
|
/// unable to use <seealso cref="PredictionMode#SLL"/>, which in turn means they cannot use
|
||||||
|
/// the two-stage parsing strategy to improve parsing performance for that
|
||||||
|
/// input.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= ParserATNSimulator#reportContextSensitivity </seealso>
|
||||||
|
/// <seealso cref= ANTLRErrorListener#reportContextSensitivity
|
||||||
|
///
|
||||||
|
/// @since 4.3 </seealso>
|
||||||
|
class ContextSensitivityInfo : public DecisionEventInfo {
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance of the <seealso cref="ContextSensitivityInfo"/> class
|
||||||
|
/// with the specified detailed context sensitivity information.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="decision"> The decision number </param>
|
||||||
|
/// <param name="configs"> The final configuration set containing the unique
|
||||||
|
/// alternative identified by full-context prediction </param>
|
||||||
|
/// <param name="input"> The input token stream </param>
|
||||||
|
/// <param name="startIndex"> The start index for the current prediction </param>
|
||||||
|
/// <param name="stopIndex"> The index at which the context sensitivity was
|
||||||
|
/// identified during full-context prediction </param>
|
||||||
|
ContextSensitivityInfo(int decision, Ref<ATNConfigSet> configs, TokenStream *input, size_t startIndex, size_t stopIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DecisionEventInfo.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime;
|
||||||
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
|
DecisionEventInfo::DecisionEventInfo(int decision, Ref<ATNConfigSet> configs, TokenStream *input, size_t startIndex,
|
||||||
|
size_t stopIndex, bool fullCtx)
|
||||||
|
: decision(decision), configs(configs), input(input), startIndex(startIndex), stopIndex(stopIndex), fullCtx(fullCtx) {
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace atn {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is the base class for gathering detailed information about prediction
|
||||||
|
/// events which occur during parsing.
|
||||||
|
///
|
||||||
|
/// Note that we could record the parser call stack at the time this event
|
||||||
|
/// occurred but in the presence of left recursive rules, the stack is kind of
|
||||||
|
/// meaningless. It's better to look at the individual configurations for their
|
||||||
|
/// individual stacks. Of course that is a <seealso cref="PredictionContext"/> object
|
||||||
|
/// not a parse tree node and so it does not have information about the extent
|
||||||
|
/// (start...stop) of the various subtrees. Examining the stack tops of all
|
||||||
|
/// configurations provide the return states for the rule invocations.
|
||||||
|
/// From there you can get the enclosing rule.
|
||||||
|
///
|
||||||
|
/// @since 4.3
|
||||||
|
/// </summary>
|
||||||
|
class DecisionEventInfo {
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// The invoked decision number which this event is related to.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= ATN#decisionToState </seealso>
|
||||||
|
const int decision;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The configuration set containing additional information relevant to the
|
||||||
|
/// prediction state when the current event occurred, or {@code null} if no
|
||||||
|
/// additional information is relevant or available.
|
||||||
|
/// </summary>
|
||||||
|
const Ref<ATNConfigSet> configs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The input token stream which is being parsed.
|
||||||
|
/// </summary>
|
||||||
|
const TokenStream *input;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The token index in the input stream at which the current prediction was
|
||||||
|
/// originally invoked.
|
||||||
|
/// </summary>
|
||||||
|
const size_t startIndex;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The token index in the input stream at which the current event occurred.
|
||||||
|
/// </summary>
|
||||||
|
const size_t stopIndex;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// {@code true} if the current event occurred during LL prediction;
|
||||||
|
/// otherwise, {@code false} if the input occurred during SLL prediction.
|
||||||
|
/// </summary>
|
||||||
|
const bool fullCtx;
|
||||||
|
|
||||||
|
DecisionEventInfo(int decision, Ref<ATNConfigSet> configs, TokenStream *input, size_t startIndex, size_t stopIndex,
|
||||||
|
bool fullCtx);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ErrorInfo.h"
|
||||||
|
#include "LookaheadEventInfo.h"
|
||||||
|
|
||||||
|
#include "DecisionInfo.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
|
DecisionInfo::DecisionInfo(size_t decision) : decision(decision) {
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring DecisionInfo::toString() const {
|
||||||
|
std::wstringstream ss;
|
||||||
|
|
||||||
|
ss << L"{decision=" << decision << L", contextSensitivities=" << contextSensitivities.size() << L", errors=";
|
||||||
|
ss << errors.size() << L", ambiguities=" << ambiguities.size() << L", SLL_lookahead=" << SLL_TotalLook;
|
||||||
|
ss << L", SLL_ATNTransitions=" << SLL_ATNTransitions << L", SLL_DFATransitions=" << SLL_DFATransitions;
|
||||||
|
ss << L", LL_Fallback=" << LL_Fallback << L", LL_lookahead=" << LL_TotalLook << L", LL_ATNTransitions=" << LL_ATNTransitions << L'}';
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ContextSensitivityInfo.h"
|
||||||
|
#include "AmbiguityInfo.h"
|
||||||
|
#include "PredicateEvalInfo.h"
|
||||||
|
#include "ErrorInfo.h"
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace atn {
|
||||||
|
|
||||||
|
class LookaheadEventInfo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class contains profiling gathered for a particular decision.
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// Parsing performance in ANTLR 4 is heavily influenced by both static factors
|
||||||
|
/// (e.g. the form of the rules in the grammar) and dynamic factors (e.g. the
|
||||||
|
/// choice of input and the state of the DFA cache at the time profiling
|
||||||
|
/// operations are started). For best results, gather and use aggregate
|
||||||
|
/// statistics from a large sample of inputs representing the inputs expected in
|
||||||
|
/// production before using the results to make changes in the grammar.</para>
|
||||||
|
///
|
||||||
|
/// @since 4.3
|
||||||
|
/// </summary>
|
||||||
|
class DecisionInfo {
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// The decision number, which is an index into <seealso cref="ATN#decisionToState"/>.
|
||||||
|
/// </summary>
|
||||||
|
const size_t decision;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total number of times <seealso cref="ParserATNSimulator#adaptivePredict"/> was
|
||||||
|
/// invoked for this decision.
|
||||||
|
/// </summary>
|
||||||
|
long long invocations = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total time spent in <seealso cref="ParserATNSimulator#adaptivePredict"/> for
|
||||||
|
/// this decision, in nanoseconds.
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The value of this field contains the sum of differential results obtained
|
||||||
|
/// by <seealso cref="System#nanoTime()"/>, and is not adjusted to compensate for JIT
|
||||||
|
/// and/or garbage collection overhead. For best accuracy, use a modern JVM
|
||||||
|
/// implementation that provides precise results from
|
||||||
|
/// <seealso cref="System#nanoTime()"/>, and perform profiling in a separate process
|
||||||
|
/// which is warmed up by parsing the input prior to profiling. If desired,
|
||||||
|
/// call <seealso cref="ATNSimulator#clearDFA"/> to reset the DFA cache to its initial
|
||||||
|
/// state before starting the profiling measurement pass.</para>
|
||||||
|
/// </summary>
|
||||||
|
long long timeInPrediction = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sum of the lookahead required for SLL prediction for this decision.
|
||||||
|
/// Note that SLL prediction is used before LL prediction for performance
|
||||||
|
/// reasons even when <seealso cref="PredictionMode#LL"/> or
|
||||||
|
/// <seealso cref="PredictionMode#LL_EXACT_AMBIG_DETECTION"/> is used.
|
||||||
|
/// </summary>
|
||||||
|
long long SLL_TotalLook = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the minimum lookahead required for any single SLL prediction to
|
||||||
|
/// complete for this decision, by reaching a unique prediction, reaching an
|
||||||
|
/// SLL conflict state, or encountering a syntax error.
|
||||||
|
/// </summary>
|
||||||
|
long long SLL_MinLook = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the maximum lookahead required for any single SLL prediction to
|
||||||
|
/// complete for this decision, by reaching a unique prediction, reaching an
|
||||||
|
/// SLL conflict state, or encountering a syntax error.
|
||||||
|
/// </summary>
|
||||||
|
long long SLL_MaxLook = 0;
|
||||||
|
|
||||||
|
/// Gets the <seealso cref="LookaheadEventInfo"/> associated with the event where the
|
||||||
|
/// <seealso cref="#SLL_MaxLook"/> value was set.
|
||||||
|
Ref<LookaheadEventInfo> SLL_MaxLookEvent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sum of the lookahead required for LL prediction for this decision.
|
||||||
|
/// Note that LL prediction is only used when SLL prediction reaches a
|
||||||
|
/// conflict state.
|
||||||
|
/// </summary>
|
||||||
|
long long LL_TotalLook = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the minimum lookahead required for any single LL prediction to
|
||||||
|
/// complete for this decision. An LL prediction completes when the algorithm
|
||||||
|
/// reaches a unique prediction, a conflict state (for
|
||||||
|
/// <seealso cref="PredictionMode#LL"/>, an ambiguity state (for
|
||||||
|
/// <seealso cref="PredictionMode#LL_EXACT_AMBIG_DETECTION"/>, or a syntax error.
|
||||||
|
/// </summary>
|
||||||
|
long long LL_MinLook = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the maximum lookahead required for any single LL prediction to
|
||||||
|
/// complete for this decision. An LL prediction completes when the algorithm
|
||||||
|
/// reaches a unique prediction, a conflict state (for
|
||||||
|
/// <seealso cref="PredictionMode#LL"/>, an ambiguity state (for
|
||||||
|
/// <seealso cref="PredictionMode#LL_EXACT_AMBIG_DETECTION"/>, or a syntax error.
|
||||||
|
/// </summary>
|
||||||
|
long long LL_MaxLook = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <seealso cref="LookaheadEventInfo"/> associated with the event where the
|
||||||
|
/// <seealso cref="#LL_MaxLook"/> value was set.
|
||||||
|
/// </summary>
|
||||||
|
Ref<LookaheadEventInfo> LL_MaxLookEvent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of <seealso cref="ContextSensitivityInfo"/> instances describing the
|
||||||
|
/// context sensitivities encountered during LL prediction for this decision.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= ContextSensitivityInfo </seealso>
|
||||||
|
std::vector<ContextSensitivityInfo> contextSensitivities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of <seealso cref="ErrorInfo"/> instances describing the parse errors
|
||||||
|
/// identified during calls to <seealso cref="ParserATNSimulator#adaptivePredict"/> for
|
||||||
|
/// this decision.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= ErrorInfo </seealso>
|
||||||
|
std::vector<ErrorInfo> errors;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of <seealso cref="AmbiguityInfo"/> instances describing the
|
||||||
|
/// ambiguities encountered during LL prediction for this decision.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= AmbiguityInfo </seealso>
|
||||||
|
std::vector<AmbiguityInfo> ambiguities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of <seealso cref="PredicateEvalInfo"/> instances describing the
|
||||||
|
/// results of evaluating individual predicates during prediction for this
|
||||||
|
/// decision.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= PredicateEvalInfo </seealso>
|
||||||
|
std::vector<PredicateEvalInfo> predicateEvals;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total number of ATN transitions required during SLL prediction for
|
||||||
|
/// this decision. An ATN transition is determined by the number of times the
|
||||||
|
/// DFA does not contain an edge that is required for prediction, resulting
|
||||||
|
/// in on-the-fly computation of that edge.
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// If DFA caching of SLL transitions is employed by the implementation, ATN
|
||||||
|
/// computation may cache the computed edge for efficient lookup during
|
||||||
|
/// future parsing of this decision. Otherwise, the SLL parsing algorithm
|
||||||
|
/// will use ATN transitions exclusively.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= #SLL_ATNTransitions </seealso>
|
||||||
|
/// <seealso cref= ParserATNSimulator#computeTargetState </seealso>
|
||||||
|
/// <seealso cref= LexerATNSimulator#computeTargetState </seealso>
|
||||||
|
long long SLL_ATNTransitions = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total number of DFA transitions required during SLL prediction for
|
||||||
|
/// this decision.
|
||||||
|
///
|
||||||
|
/// <para>If the ATN simulator implementation does not use DFA caching for SLL
|
||||||
|
/// transitions, this value will be 0.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= ParserATNSimulator#getExistingTargetState </seealso>
|
||||||
|
/// <seealso cref= LexerATNSimulator#getExistingTargetState </seealso>
|
||||||
|
long long SLL_DFATransitions = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the total number of times SLL prediction completed in a conflict
|
||||||
|
/// state, resulting in fallback to LL prediction.
|
||||||
|
///
|
||||||
|
/// <para>Note that this value is not related to whether or not
|
||||||
|
/// <seealso cref="PredictionMode#SLL"/> may be used successfully with a particular
|
||||||
|
/// grammar. If the ambiguity resolution algorithm applied to the SLL
|
||||||
|
/// conflicts for this decision produce the same result as LL prediction for
|
||||||
|
/// this decision, <seealso cref="PredictionMode#SLL"/> would produce the same overall
|
||||||
|
/// parsing result as <seealso cref="PredictionMode#LL"/>.</para>
|
||||||
|
/// </summary>
|
||||||
|
long long LL_Fallback = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total number of ATN transitions required during LL prediction for
|
||||||
|
/// this decision. An ATN transition is determined by the number of times the
|
||||||
|
/// DFA does not contain an edge that is required for prediction, resulting
|
||||||
|
/// in on-the-fly computation of that edge.
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// If DFA caching of LL transitions is employed by the implementation, ATN
|
||||||
|
/// computation may cache the computed edge for efficient lookup during
|
||||||
|
/// future parsing of this decision. Otherwise, the LL parsing algorithm will
|
||||||
|
/// use ATN transitions exclusively.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= #LL_DFATransitions </seealso>
|
||||||
|
/// <seealso cref= ParserATNSimulator#computeTargetState </seealso>
|
||||||
|
/// <seealso cref= LexerATNSimulator#computeTargetState </seealso>
|
||||||
|
long long LL_ATNTransitions = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total number of DFA transitions required during LL prediction for
|
||||||
|
/// this decision.
|
||||||
|
///
|
||||||
|
/// <para>If the ATN simulator implementation does not use DFA caching for LL
|
||||||
|
/// transitions, this value will be 0.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= ParserATNSimulator#getExistingTargetState </seealso>
|
||||||
|
/// <seealso cref= LexerATNSimulator#getExistingTargetState </seealso>
|
||||||
|
long long LL_DFATransitions = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance of the <seealso cref="DecisionInfo"/> class to contain
|
||||||
|
/// statistics for a particular decision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="decision"> The decision number </param>
|
||||||
|
DecisionInfo(size_t decision);
|
||||||
|
|
||||||
|
std::wstring toString() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ATNConfigSet.h"
|
||||||
|
|
||||||
|
#include "ErrorInfo.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime;
|
||||||
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
|
||||||
|
ErrorInfo::ErrorInfo(int decision, Ref<ATNConfigSet> configs, TokenStream *input, int startIndex, int stopIndex, bool fullCtx)
|
||||||
|
: DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) {
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 Sam Harwell
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "DecisionEventInfo.h"
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace atn {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents profiling event information for a syntax error
|
||||||
|
/// identified during prediction. Syntax errors occur when the prediction
|
||||||
|
/// algorithm is unable to identify an alternative which would lead to a
|
||||||
|
/// successful parse.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref= Parser#notifyErrorListeners(Token, String, RecognitionException) </seealso>
|
||||||
|
/// <seealso cref= ANTLRErrorListener#syntaxError
|
||||||
|
///
|
||||||
|
/// @since 4.3 </seealso>
|
||||||
|
class ErrorInfo : public DecisionEventInfo {
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance of the <seealso cref="ErrorInfo"/> class with the
|
||||||
|
/// specified detailed syntax error information.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="decision"> The decision number </param>
|
||||||
|
/// <param name="configs"> The final configuration set reached during prediction
|
||||||
|
/// prior to reaching the <seealso cref="ATNSimulator#ERROR"/> state </param>
|
||||||
|
/// <param name="input"> The input token stream </param>
|
||||||
|
/// <param name="startIndex"> The start index for the current prediction </param>
|
||||||
|
/// <param name="stopIndex"> The index at which the syntax error was identified </param>
|
||||||
|
/// <param name="fullCtx"> {@code true} if the syntax error was identified during LL
|
||||||
|
/// prediction; otherwise, {@code false} if the syntax error was identified
|
||||||
|
/// during SLL prediction </param>
|
||||||
|
ErrorInfo(int decision, Ref<ATNConfigSet> configs, TokenStream *input, int startIndex, int stopIndex, bool fullCtx);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -40,6 +40,8 @@
|
||||||
#include "ATNConfig.h"
|
#include "ATNConfig.h"
|
||||||
#include "EmptyPredictionContext.h"
|
#include "EmptyPredictionContext.h"
|
||||||
|
|
||||||
|
#include "CPPUtils.h"
|
||||||
|
|
||||||
#include "LL1Analyzer.h"
|
#include "LL1Analyzer.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime;
|
using namespace org::antlr::v4::runtime;
|
||||||
|
@ -60,7 +62,7 @@ std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) co
|
||||||
for (size_t alt = 0; alt < s->getNumberOfTransitions(); alt++) {
|
for (size_t alt = 0; alt < s->getNumberOfTransitions(); alt++) {
|
||||||
bool seeThruPreds = false; // fail to get lookahead upon pred
|
bool seeThruPreds = false; // fail to get lookahead upon pred
|
||||||
|
|
||||||
std::unordered_set<ATNConfig::Ref> lookBusy;
|
std::unordered_set<Ref<ATNConfig>> lookBusy;
|
||||||
antlrcpp::BitSet callRuleStack;
|
antlrcpp::BitSet callRuleStack;
|
||||||
_LOOK(s->transition(alt)->target, nullptr, PredictionContext::EMPTY,
|
_LOOK(s->transition(alt)->target, nullptr, PredictionContext::EMPTY,
|
||||||
look[alt], lookBusy, callRuleStack, seeThruPreds, false);
|
look[alt], lookBusy, callRuleStack, seeThruPreds, false);
|
||||||
|
@ -74,25 +76,25 @@ std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) co
|
||||||
return look;
|
return look;
|
||||||
}
|
}
|
||||||
|
|
||||||
misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, RuleContext::Ref ctx) const {
|
misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, Ref<RuleContext> ctx) const {
|
||||||
return LOOK(s, nullptr, ctx);
|
return LOOK(s, nullptr, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, ATNState *stopState, RuleContext::Ref ctx) const {
|
misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, ATNState *stopState, Ref<RuleContext> ctx) const {
|
||||||
misc::IntervalSet r;
|
misc::IntervalSet r;
|
||||||
bool seeThruPreds = true; // ignore preds; get all lookahead
|
bool seeThruPreds = true; // ignore preds; get all lookahead
|
||||||
PredictionContext::Ref lookContext = ctx != nullptr ? PredictionContext::fromRuleContext(_atn, ctx) : nullptr;
|
Ref<PredictionContext> lookContext = ctx != nullptr ? PredictionContext::fromRuleContext(_atn, ctx) : nullptr;
|
||||||
|
|
||||||
std::unordered_set<ATNConfig::Ref> lookBusy;
|
std::unordered_set<Ref<ATNConfig>> lookBusy;
|
||||||
antlrcpp::BitSet callRuleStack;
|
antlrcpp::BitSet callRuleStack;
|
||||||
_LOOK(s, stopState, lookContext, r, lookBusy, callRuleStack, seeThruPreds, true);
|
_LOOK(s, stopState, lookContext, r, lookBusy, callRuleStack, seeThruPreds, true);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, PredictionContext::Ref ctx, misc::IntervalSet &look,
|
void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext> ctx, misc::IntervalSet &look,
|
||||||
std::unordered_set<ATNConfig::Ref> &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const {
|
std::unordered_set<Ref<ATNConfig>> &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const {
|
||||||
ATNConfig::Ref c = std::make_shared<ATNConfig>(s, 0, ctx);
|
Ref<ATNConfig> c = std::make_shared<ATNConfig>(s, 0, ctx);
|
||||||
|
|
||||||
if (lookBusy.count(c) > 0) // Keep in mind comparison is based on members of the class, not the actual instance.
|
if (lookBusy.count(c) > 0) // Keep in mind comparison is based on members of the class, not the actual instance.
|
||||||
return;
|
return;
|
||||||
|
@ -146,7 +148,7 @@ void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, PredictionContext::Ref
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PredictionContext::Ref newContext = SingletonPredictionContext::create(ctx, (static_cast<RuleTransition*>(t))->followState->stateNumber);
|
Ref<PredictionContext> newContext = SingletonPredictionContext::create(ctx, (static_cast<RuleTransition*>(t))->followState->stateNumber);
|
||||||
auto onExit = finally([&] {
|
auto onExit = finally([&] {
|
||||||
calledRuleStack[(size_t)((static_cast<RuleTransition*>(t))->target->ruleIndex)] = false;
|
calledRuleStack[(size_t)((static_cast<RuleTransition*>(t))->target->ruleIndex)] = false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace atn {
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns> The set of tokens that can follow {@code s} in the ATN in the
|
/// <returns> The set of tokens that can follow {@code s} in the ATN in the
|
||||||
/// specified {@code ctx}. </returns>
|
/// specified {@code ctx}. </returns>
|
||||||
virtual misc::IntervalSet LOOK(ATNState *s, RuleContext::Ref ctx) const;
|
virtual misc::IntervalSet LOOK(ATNState *s, Ref<RuleContext> ctx) const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compute set of tokens that can follow {@code s} in the ATN in the
|
/// Compute set of tokens that can follow {@code s} in the ATN in the
|
||||||
|
@ -99,7 +99,7 @@ namespace atn {
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns> The set of tokens that can follow {@code s} in the ATN in the
|
/// <returns> The set of tokens that can follow {@code s} in the ATN in the
|
||||||
/// specified {@code ctx}. </returns>
|
/// specified {@code ctx}. </returns>
|
||||||
virtual misc::IntervalSet LOOK(ATNState *s, ATNState *stopState, RuleContext::Ref ctx) const;
|
virtual misc::IntervalSet LOOK(ATNState *s, ATNState *stopState, Ref<RuleContext> ctx) const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compute set of tokens that can follow {@code s} in the ATN in the
|
/// Compute set of tokens that can follow {@code s} in the ATN in the
|
||||||
|
@ -131,8 +131,8 @@ namespace atn {
|
||||||
/// outermost context is reached. This parameter has no effect if {@code ctx}
|
/// outermost context is reached. This parameter has no effect if {@code ctx}
|
||||||
/// is {@code null}. </param>
|
/// is {@code null}. </param>
|
||||||
protected:
|
protected:
|
||||||
virtual void _LOOK(ATNState *s, ATNState *stopState, PredictionContext::Ref ctx, misc::IntervalSet &look,
|
virtual void _LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext> ctx, misc::IntervalSet &look,
|
||||||
std::unordered_set<ATNConfig::Ref> &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const;
|
std::unordered_set<Ref<ATNConfig>> &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace atn
|
} // namespace atn
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "DecisionState.h"
|
#include "DecisionState.h"
|
||||||
#include "PredictionContext.h"
|
#include "PredictionContext.h"
|
||||||
#include "SemanticContext.h"
|
#include "SemanticContext.h"
|
||||||
|
#include "LexerActionExecutor.h"
|
||||||
|
|
||||||
#include "CPPUtils.h"
|
#include "CPPUtils.h"
|
||||||
|
|
||||||
#include "LexerATNConfig.h"
|
#include "LexerATNConfig.h"
|
||||||
|
@ -40,32 +42,37 @@
|
||||||
using namespace org::antlr::v4::runtime::atn;
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
using namespace antlrcpp;
|
using namespace antlrcpp;
|
||||||
|
|
||||||
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, PredictionContext::Ref context)
|
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> context)
|
||||||
: ATNConfig(state, alt, context, SemanticContext::NONE), passedThroughNonGreedyDecision(false) {
|
: ATNConfig(state, alt, context, SemanticContext::NONE), _passedThroughNonGreedyDecision(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, PredictionContext::Ref context, int actionIndex)
|
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> context,
|
||||||
: ATNConfig(state, alt, context, SemanticContext::NONE), passedThroughNonGreedyDecision(false) {
|
Ref<LexerActionExecutor> lexerActionExecutor)
|
||||||
lexerActionIndex = actionIndex;
|
: ATNConfig(state, alt, context, SemanticContext::NONE), _passedThroughNonGreedyDecision(false),
|
||||||
|
_lexerActionExecutor(lexerActionExecutor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerATNConfig::LexerATNConfig(LexerATNConfig::Ref c, ATNState *state)
|
LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state)
|
||||||
: ATNConfig(c, state, c->context, c->semanticContext), passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
|
: ATNConfig(c, state, c->context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)),
|
||||||
lexerActionIndex = c->lexerActionIndex;
|
_lexerActionExecutor(c->_lexerActionExecutor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerATNConfig::LexerATNConfig(LexerATNConfig::Ref c, ATNState *state, int actionIndex)
|
LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<LexerActionExecutor> lexerActionExecutor)
|
||||||
: ATNConfig(c, state, c->context, c->semanticContext), passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
|
: ATNConfig(c, state, c->context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)),
|
||||||
lexerActionIndex = actionIndex;
|
_lexerActionExecutor(lexerActionExecutor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerATNConfig::LexerATNConfig(LexerATNConfig::Ref c, ATNState *state, PredictionContext::Ref context)
|
LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<PredictionContext> context)
|
||||||
: ATNConfig(c, state, context, c->semanticContext), passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
|
: ATNConfig(c, state, context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)),
|
||||||
lexerActionIndex = c->lexerActionIndex;
|
_lexerActionExecutor(c->_lexerActionExecutor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<LexerActionExecutor> LexerATNConfig::getLexerActionExecutor() const {
|
||||||
|
return _lexerActionExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LexerATNConfig::hasPassedThroughNonGreedyDecision() {
|
bool LexerATNConfig::hasPassedThroughNonGreedyDecision() {
|
||||||
return passedThroughNonGreedyDecision;
|
return _passedThroughNonGreedyDecision;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t LexerATNConfig::hashCode() const {
|
size_t LexerATNConfig::hashCode() const {
|
||||||
|
@ -74,20 +81,25 @@ size_t LexerATNConfig::hashCode() const {
|
||||||
hashCode = misc::MurmurHash::update(hashCode, (size_t)alt);
|
hashCode = misc::MurmurHash::update(hashCode, (size_t)alt);
|
||||||
hashCode = misc::MurmurHash::update(hashCode, (size_t)context.get());
|
hashCode = misc::MurmurHash::update(hashCode, (size_t)context.get());
|
||||||
hashCode = misc::MurmurHash::update(hashCode, (size_t)semanticContext.get());
|
hashCode = misc::MurmurHash::update(hashCode, (size_t)semanticContext.get());
|
||||||
hashCode = misc::MurmurHash::update(hashCode, passedThroughNonGreedyDecision ? 1 : 0);
|
hashCode = misc::MurmurHash::update(hashCode, _passedThroughNonGreedyDecision ? 1 : 0);
|
||||||
hashCode = misc::MurmurHash::finish(hashCode, 5);
|
hashCode = misc::MurmurHash::update(hashCode, (size_t)_lexerActionExecutor.get());
|
||||||
|
hashCode = misc::MurmurHash::finish(hashCode, 6);
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LexerATNConfig::operator == (const LexerATNConfig& other) const
|
bool LexerATNConfig::operator == (const LexerATNConfig& other) const
|
||||||
{
|
{
|
||||||
if (passedThroughNonGreedyDecision != other.passedThroughNonGreedyDecision)
|
if (_passedThroughNonGreedyDecision != other._passedThroughNonGreedyDecision)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (_lexerActionExecutor != other._lexerActionExecutor) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return ATNConfig::operator == (other);
|
return ATNConfig::operator == (other);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LexerATNConfig::checkNonGreedyDecision(LexerATNConfig::Ref source, ATNState *target) {
|
bool LexerATNConfig::checkNonGreedyDecision(Ref<LexerATNConfig> source, ATNState *target) {
|
||||||
return source->passedThroughNonGreedyDecision ||
|
return source->_passedThroughNonGreedyDecision ||
|
||||||
(is<DecisionState*>(target) && (static_cast<DecisionState*>(target))->nonGreedy);
|
(is<DecisionState*>(target) && (static_cast<DecisionState*>(target))->nonGreedy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,18 +41,18 @@ namespace atn {
|
||||||
|
|
||||||
class LexerATNConfig : public ATNConfig {
|
class LexerATNConfig : public ATNConfig {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<LexerATNConfig> Ref;
|
LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> context);
|
||||||
|
LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> context, Ref<LexerActionExecutor> lexerActionExecutor);
|
||||||
|
|
||||||
/// Capture lexer action we traverse.
|
LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state);
|
||||||
int lexerActionIndex = -1;
|
LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<LexerActionExecutor> lexerActionExecutor);
|
||||||
|
LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<PredictionContext> context);
|
||||||
explicit LexerATNConfig(ATNState *state, int alt, PredictionContext::Ref context);
|
|
||||||
explicit LexerATNConfig(ATNState *state, int alt, PredictionContext::Ref context, int actionIndex);
|
|
||||||
|
|
||||||
explicit LexerATNConfig(LexerATNConfig::Ref c, ATNState *state);
|
|
||||||
explicit LexerATNConfig(LexerATNConfig::Ref c, ATNState *state, int actionIndex);
|
|
||||||
explicit LexerATNConfig(LexerATNConfig::Ref c, ATNState *state, PredictionContext::Ref context);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link LexerActionExecutor} capable of executing the embedded
|
||||||
|
* action(s) for the current configuration.
|
||||||
|
*/
|
||||||
|
Ref<LexerActionExecutor> getLexerActionExecutor() const;
|
||||||
bool hasPassedThroughNonGreedyDecision();
|
bool hasPassedThroughNonGreedyDecision();
|
||||||
|
|
||||||
virtual size_t hashCode() const override;
|
virtual size_t hashCode() const override;
|
||||||
|
@ -60,9 +60,13 @@ namespace atn {
|
||||||
bool operator == (const LexerATNConfig& other) const;
|
bool operator == (const LexerATNConfig& other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const bool passedThroughNonGreedyDecision;
|
/**
|
||||||
|
* This is the backing field for {@link #getLexerActionExecutor}.
|
||||||
|
*/
|
||||||
|
const Ref<LexerActionExecutor> _lexerActionExecutor;
|
||||||
|
const bool _passedThroughNonGreedyDecision;
|
||||||
|
|
||||||
static bool checkNonGreedyDecision(LexerATNConfig::Ref source, ATNState *target);
|
static bool checkNonGreedyDecision(Ref<LexerATNConfig> source, ATNState *target);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace atn
|
} // namespace atn
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
#include "DFAState.h"
|
#include "DFAState.h"
|
||||||
#include "LexerATNConfig.h"
|
#include "LexerATNConfig.h"
|
||||||
|
#include "LexerActionExecutor.h"
|
||||||
#include "EmptyPredictionContext.h"
|
#include "EmptyPredictionContext.h"
|
||||||
|
|
||||||
#include "LexerATNSimulator.h"
|
#include "LexerATNSimulator.h"
|
||||||
|
@ -69,12 +70,12 @@ int LexerATNSimulator::match_calls = 0;
|
||||||
|
|
||||||
|
|
||||||
LexerATNSimulator::LexerATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
LexerATNSimulator::LexerATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
||||||
std::shared_ptr<PredictionContextCache> sharedContextCache)
|
Ref<PredictionContextCache> sharedContextCache)
|
||||||
: LexerATNSimulator(nullptr, atn, decisionToDFA, sharedContextCache) {
|
: LexerATNSimulator(nullptr, atn, decisionToDFA, sharedContextCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerATNSimulator::LexerATNSimulator(Lexer *recog, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
LexerATNSimulator::LexerATNSimulator(Lexer *recog, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
||||||
std::shared_ptr<PredictionContextCache> sharedContextCache)
|
Ref<PredictionContextCache> sharedContextCache)
|
||||||
: ATNSimulator(atn, sharedContextCache), _recog(recog), _decisionToDFA(decisionToDFA) {
|
: ATNSimulator(atn, sharedContextCache), _recog(recog), _decisionToDFA(decisionToDFA) {
|
||||||
InitializeInstanceFields();
|
InitializeInstanceFields();
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ int LexerATNSimulator::match(CharStream *input, size_t mode) {
|
||||||
});
|
});
|
||||||
|
|
||||||
_startIndex = (int)input->index();
|
_startIndex = (int)input->index();
|
||||||
prevAccept.reset();
|
_prevAccept.reset();
|
||||||
const dfa::DFA &dfa = _decisionToDFA[mode];
|
const dfa::DFA &dfa = _decisionToDFA[mode];
|
||||||
if (dfa.s0 == nullptr) {
|
if (dfa.s0 == nullptr) {
|
||||||
return matchATN(input);
|
return matchATN(input);
|
||||||
|
@ -108,7 +109,7 @@ int LexerATNSimulator::match(CharStream *input, size_t mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerATNSimulator::reset() {
|
void LexerATNSimulator::reset() {
|
||||||
prevAccept.reset();
|
_prevAccept.reset();
|
||||||
_startIndex = 0; // Originally -1, but that would require a signed type with many casts.
|
_startIndex = 0; // Originally -1, but that would require a signed type with many casts.
|
||||||
// The initial value is never tested, so it doesn't matter which value is set here.
|
// The initial value is never tested, so it doesn't matter which value is set here.
|
||||||
_line = 1;
|
_line = 1;
|
||||||
|
@ -116,6 +117,14 @@ void LexerATNSimulator::reset() {
|
||||||
_mode = Lexer::DEFAULT_MODE;
|
_mode = Lexer::DEFAULT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LexerATNSimulator::clearDFA() {
|
||||||
|
int size = (int)_decisionToDFA.size();
|
||||||
|
_decisionToDFA.clear();
|
||||||
|
for (int d = 0; d < size; ++d) {
|
||||||
|
_decisionToDFA.push_back(dfa::DFA(atn.getDecisionState(d), d));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int LexerATNSimulator::matchATN(CharStream *input) {
|
int LexerATNSimulator::matchATN(CharStream *input) {
|
||||||
ATNState *startState = (ATNState *)atn.modeToStartState[_mode];
|
ATNState *startState = (ATNState *)atn.modeToStartState[_mode];
|
||||||
|
|
||||||
|
@ -125,7 +134,7 @@ int LexerATNSimulator::matchATN(CharStream *input) {
|
||||||
|
|
||||||
size_t old_mode = _mode;
|
size_t old_mode = _mode;
|
||||||
|
|
||||||
std::shared_ptr<ATNConfigSet> s0_closure = computeStartState(input, startState);
|
Ref<ATNConfigSet> s0_closure = computeStartState(input, startState);
|
||||||
bool suppressEdge = s0_closure->hasSemanticContext;
|
bool suppressEdge = s0_closure->hasSemanticContext;
|
||||||
s0_closure->hasSemanticContext = false;
|
s0_closure->hasSemanticContext = false;
|
||||||
|
|
||||||
|
@ -149,6 +158,12 @@ int LexerATNSimulator::execATN(CharStream *input, dfa::DFAState *ds0) {
|
||||||
std::wcout << L"start state closure=" << ds0->configs << std::endl;
|
std::wcout << L"start state closure=" << ds0->configs << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ds0->isAcceptState) {
|
||||||
|
// allow zero-length tokens
|
||||||
|
// ml: in Java code this method uses 3 params. The first is a member var of the class anyway (_prevAccept), so why pass it here?
|
||||||
|
captureSimState(input, ds0);
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t t = input->LA(1);
|
ssize_t t = input->LA(1);
|
||||||
dfa::DFAState *s = ds0; // s is current/from DFA state
|
dfa::DFAState *s = ds0; // s is current/from DFA state
|
||||||
|
|
||||||
|
@ -183,6 +198,14 @@ int LexerATNSimulator::execATN(CharStream *input, dfa::DFAState *ds0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a consumable input element, make sure to consume before
|
||||||
|
// capturing the accept state so the input index, line, and char
|
||||||
|
// position accurately reflect the state of the interpreter at the
|
||||||
|
// end of the token.
|
||||||
|
if (t != EOF) {
|
||||||
|
consume(input);
|
||||||
|
}
|
||||||
|
|
||||||
if (target->isAcceptState) {
|
if (target->isAcceptState) {
|
||||||
captureSimState(input, target);
|
captureSimState(input, target);
|
||||||
if (t == EOF) {
|
if (t == EOF) {
|
||||||
|
@ -190,11 +213,7 @@ int LexerATNSimulator::execATN(CharStream *input, dfa::DFAState *ds0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t != EOF) {
|
|
||||||
consume(input);
|
|
||||||
t = input->LA(1);
|
t = input->LA(1);
|
||||||
}
|
|
||||||
|
|
||||||
s = target; // flip; current DFA target becomes new src/from state
|
s = target; // flip; current DFA target becomes new src/from state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,16 +234,19 @@ dfa::DFAState *LexerATNSimulator::getExistingTargetState(dfa::DFAState *s, ssize
|
||||||
}
|
}
|
||||||
|
|
||||||
dfa::DFAState *LexerATNSimulator::computeTargetState(CharStream *input, dfa::DFAState *s, ssize_t t) {
|
dfa::DFAState *LexerATNSimulator::computeTargetState(CharStream *input, dfa::DFAState *s, ssize_t t) {
|
||||||
std::shared_ptr<OrderedATNConfigSet> reach = std::make_shared<OrderedATNConfigSet>();
|
Ref<OrderedATNConfigSet> reach = std::make_shared<OrderedATNConfigSet>();
|
||||||
|
|
||||||
// if we don't find an existing DFA state
|
// if we don't find an existing DFA state
|
||||||
// Fill reach starting from closure, following t transitions
|
// Fill reach starting from closure, following t transitions
|
||||||
getReachableConfigSet(input, s->configs, reach, t);
|
getReachableConfigSet(input, s->configs, reach, t);
|
||||||
|
|
||||||
if (reach->isEmpty()) { // we got nowhere on t from s
|
if (reach->isEmpty()) { // we got nowhere on t from s
|
||||||
|
if (!reach->hasSemanticContext) {
|
||||||
// we got nowhere on t, don't throw out this knowledge; it'd
|
// we got nowhere on t, don't throw out this knowledge; it'd
|
||||||
// cause a failover from DFA later.
|
// cause a failover from DFA later.
|
||||||
addDFAEdge(s, t, ERROR.get());
|
addDFAEdge(s, t, ERROR.get());
|
||||||
|
}
|
||||||
|
|
||||||
// stop when we can't match any more char
|
// stop when we can't match any more char
|
||||||
return ERROR.get();
|
return ERROR.get();
|
||||||
}
|
}
|
||||||
|
@ -233,12 +255,11 @@ dfa::DFAState *LexerATNSimulator::computeTargetState(CharStream *input, dfa::DFA
|
||||||
return addDFAEdge(s, t, reach);
|
return addDFAEdge(s, t, reach);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LexerATNSimulator::failOrAccept(CharStream *input, std::shared_ptr<ATNConfigSet> reach, ssize_t t) {
|
int LexerATNSimulator::failOrAccept(CharStream *input, Ref<ATNConfigSet> reach, ssize_t t) {
|
||||||
if (prevAccept.dfaState != nullptr) {
|
if (_prevAccept.dfaState != nullptr) {
|
||||||
int ruleIndex = prevAccept.dfaState->lexerRuleIndex;
|
Ref<LexerActionExecutor> lexerActionExecutor = _prevAccept.dfaState->lexerActionExecutor;
|
||||||
int actionIndex = prevAccept.dfaState->lexerActionIndex;
|
accept(input, lexerActionExecutor, _startIndex, (size_t)_prevAccept.index, _prevAccept.line, (size_t)_prevAccept.charPos);
|
||||||
accept(input, ruleIndex, actionIndex, (size_t)prevAccept.index, prevAccept.line, (size_t)prevAccept.charPos);
|
return _prevAccept.dfaState->prediction;
|
||||||
return prevAccept.dfaState->prediction;
|
|
||||||
} else {
|
} else {
|
||||||
// if no accept and EOF is first char, return EOF
|
// if no accept and EOF is first char, return EOF
|
||||||
if (t == EOF && input->index() == (size_t)_startIndex) {
|
if (t == EOF && input->index() == (size_t)_startIndex) {
|
||||||
|
@ -249,13 +270,13 @@ int LexerATNSimulator::failOrAccept(CharStream *input, std::shared_ptr<ATNConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerATNSimulator::getReachableConfigSet(CharStream *input, std::shared_ptr<ATNConfigSet> closure,
|
void LexerATNSimulator::getReachableConfigSet(CharStream *input, Ref<ATNConfigSet> closure_,
|
||||||
std::shared_ptr<ATNConfigSet> reach, ssize_t t) {
|
Ref<ATNConfigSet> reach, ssize_t t) {
|
||||||
// this is used to skip processing for configs which have a lower priority
|
// this is used to skip processing for configs which have a lower priority
|
||||||
// than a config that already reached an accept state for the same rule
|
// than a config that already reached an accept state for the same rule
|
||||||
int skipAlt = ATN::INVALID_ALT_NUMBER;
|
int skipAlt = ATN::INVALID_ALT_NUMBER;
|
||||||
|
|
||||||
for (auto c : closure->configs) {
|
for (auto c : closure_->configs) {
|
||||||
bool currentAltReachedAcceptState = c->alt == skipAlt;
|
bool currentAltReachedAcceptState = c->alt == skipAlt;
|
||||||
if (currentAltReachedAcceptState && (std::static_pointer_cast<LexerATNConfig>(c))->hasPassedThroughNonGreedyDecision()) {
|
if (currentAltReachedAcceptState && (std::static_pointer_cast<LexerATNConfig>(c))->hasPassedThroughNonGreedyDecision()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -270,8 +291,16 @@ void LexerATNSimulator::getReachableConfigSet(CharStream *input, std::shared_ptr
|
||||||
Transition *trans = c->state->transition(ti);
|
Transition *trans = c->state->transition(ti);
|
||||||
ATNState *target = getReachableTarget(trans, (int)t);
|
ATNState *target = getReachableTarget(trans, (int)t);
|
||||||
if (target != nullptr) {
|
if (target != nullptr) {
|
||||||
if (this->closure(input, std::make_shared<LexerATNConfig>(std::static_pointer_cast<LexerATNConfig>(c), target),
|
Ref<LexerActionExecutor> lexerActionExecutor = std::static_pointer_cast<LexerATNConfig>(c)->getLexerActionExecutor();
|
||||||
reach, currentAltReachedAcceptState, true)) {
|
if (lexerActionExecutor != nullptr) {
|
||||||
|
lexerActionExecutor = lexerActionExecutor->fixOffsetBeforeMatch((int)input->index() - _startIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool treatEofAsEpsilon = t == EOF;
|
||||||
|
Ref<LexerATNConfig> config = std::make_shared<LexerATNConfig>(std::static_pointer_cast<LexerATNConfig>(c),
|
||||||
|
target, lexerActionExecutor);
|
||||||
|
|
||||||
|
if (closure(input, config, reach, currentAltReachedAcceptState, true, treatEofAsEpsilon)) {
|
||||||
// any remaining configs for this alt have a lower priority than
|
// any remaining configs for this alt have a lower priority than
|
||||||
// the one that just reached an accept state.
|
// the one that just reached an accept state.
|
||||||
skipAlt = c->alt;
|
skipAlt = c->alt;
|
||||||
|
@ -282,27 +311,20 @@ void LexerATNSimulator::getReachableConfigSet(CharStream *input, std::shared_ptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerATNSimulator::accept(CharStream *input, int ruleIndex, int actionIndex, size_t index, size_t line, size_t charPos) {
|
void LexerATNSimulator::accept(CharStream *input, Ref<LexerActionExecutor> lexerActionExecutor, int startIndex,
|
||||||
|
size_t index, size_t line, size_t charPos) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
std::wcout << L"ACTION ";
|
std::wcout << L"ACTION ";
|
||||||
if (_recog != nullptr) {
|
std::wcout << toString(lexerActionExecutor) << std::endl;
|
||||||
std::wcout << _recog->getRuleNames()[(size_t)ruleIndex];
|
|
||||||
} else {
|
|
||||||
std::wcout << ruleIndex;
|
|
||||||
}
|
|
||||||
std::wcout << ":" << actionIndex << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actionIndex >= 0 && _recog != nullptr) {
|
|
||||||
_recog->action(nullptr, ruleIndex, actionIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// seek to after last char in token
|
// seek to after last char in token
|
||||||
input->seek(index);
|
input->seek(index);
|
||||||
_line = line;
|
_line = line;
|
||||||
_charPositionInLine = (int)charPos;
|
_charPositionInLine = (int)charPos;
|
||||||
if (input->LA(1) != EOF) {
|
|
||||||
consume(input);
|
if (lexerActionExecutor != nullptr && _recog != nullptr) {
|
||||||
|
lexerActionExecutor->execute(_recog, input, _startIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,19 +336,19 @@ atn::ATNState *LexerATNSimulator::getReachableTarget(Transition *trans, ssize_t
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ATNConfigSet> LexerATNSimulator::computeStartState(CharStream *input, ATNState *p) {
|
Ref<ATNConfigSet> LexerATNSimulator::computeStartState(CharStream *input, ATNState *p) {
|
||||||
std::shared_ptr<PredictionContext> initialContext = PredictionContext::EMPTY; // ml: the purpose of this assignment is unclear
|
Ref<PredictionContext> initialContext = PredictionContext::EMPTY; // ml: the purpose of this assignment is unclear
|
||||||
std::shared_ptr<ATNConfigSet> configs = std::make_shared<OrderedATNConfigSet>();
|
Ref<ATNConfigSet> configs = std::make_shared<OrderedATNConfigSet>();
|
||||||
for (size_t i = 0; i < p->getNumberOfTransitions(); i++) {
|
for (size_t i = 0; i < p->getNumberOfTransitions(); i++) {
|
||||||
ATNState *target = p->transition(i)->target;
|
ATNState *target = p->transition(i)->target;
|
||||||
LexerATNConfig::Ref c = std::make_shared<LexerATNConfig>(target, (int)(i + 1), initialContext);
|
Ref<LexerATNConfig> c = std::make_shared<LexerATNConfig>(target, (int)(i + 1), initialContext);
|
||||||
closure(input, c, configs, false, false);
|
closure(input, c, configs, false, false, false);
|
||||||
}
|
}
|
||||||
return configs;
|
return configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LexerATNSimulator::closure(CharStream *input, LexerATNConfig::Ref config, std::shared_ptr<ATNConfigSet> configs,
|
bool LexerATNSimulator::closure(CharStream *input, Ref<LexerATNConfig> config, Ref<ATNConfigSet> configs,
|
||||||
bool currentAltReachedAcceptState, bool speculative) {
|
bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
std::wcout << L"closure(" << config->toString(true) << L")" << std::endl;
|
std::wcout << L"closure(" << config->toString(true) << L")" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -355,8 +377,8 @@ bool LexerATNSimulator::closure(CharStream *input, LexerATNConfig::Ref config, s
|
||||||
if (config->context->getReturnState(i) != PredictionContext::EMPTY_RETURN_STATE) {
|
if (config->context->getReturnState(i) != PredictionContext::EMPTY_RETURN_STATE) {
|
||||||
std::weak_ptr<PredictionContext> newContext = config->context->getParent(i); // "pop" return state
|
std::weak_ptr<PredictionContext> newContext = config->context->getParent(i); // "pop" return state
|
||||||
ATNState *returnState = atn.states[(size_t)config->context->getReturnState(i)];
|
ATNState *returnState = atn.states[(size_t)config->context->getReturnState(i)];
|
||||||
LexerATNConfig::Ref c = std::make_shared<LexerATNConfig>(returnState, config->alt, newContext.lock());
|
Ref<LexerATNConfig> c = std::make_shared<LexerATNConfig>(config, returnState, newContext.lock());
|
||||||
currentAltReachedAcceptState = closure(input, c, configs, currentAltReachedAcceptState, speculative);
|
currentAltReachedAcceptState = closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,22 +396,23 @@ bool LexerATNSimulator::closure(CharStream *input, LexerATNConfig::Ref config, s
|
||||||
ATNState *p = config->state;
|
ATNState *p = config->state;
|
||||||
for (size_t i = 0; i < p->getNumberOfTransitions(); i++) {
|
for (size_t i = 0; i < p->getNumberOfTransitions(); i++) {
|
||||||
Transition *t = p->transition(i);
|
Transition *t = p->transition(i);
|
||||||
LexerATNConfig::Ref c = getEpsilonTarget(input, config, t, configs, speculative);
|
Ref<LexerATNConfig> c = getEpsilonTarget(input, config, t, configs, speculative, treatEofAsEpsilon);
|
||||||
if (c != nullptr) {
|
if (c != nullptr) {
|
||||||
currentAltReachedAcceptState = closure(input, c, configs, currentAltReachedAcceptState, speculative);
|
currentAltReachedAcceptState = closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentAltReachedAcceptState;
|
return currentAltReachedAcceptState;
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerATNConfig::Ref LexerATNSimulator::getEpsilonTarget(CharStream *input, LexerATNConfig::Ref config, Transition *t,
|
Ref<LexerATNConfig> LexerATNSimulator::getEpsilonTarget(CharStream *input, Ref<LexerATNConfig> config, Transition *t,
|
||||||
std::shared_ptr<ATNConfigSet> configs, bool speculative) {
|
Ref<ATNConfigSet> configs, bool speculative, bool treatEofAsEpsilon) {
|
||||||
LexerATNConfig::Ref c = nullptr;
|
|
||||||
|
Ref<LexerATNConfig> c = nullptr;
|
||||||
switch (t->getSerializationType()) {
|
switch (t->getSerializationType()) {
|
||||||
case Transition::RULE: {
|
case Transition::RULE: {
|
||||||
RuleTransition *ruleTransition = static_cast<RuleTransition*>(t);
|
RuleTransition *ruleTransition = static_cast<RuleTransition*>(t);
|
||||||
PredictionContext::Ref newContext = SingletonPredictionContext::create(config->context, ruleTransition->followState->stateNumber);
|
Ref<PredictionContext> newContext = SingletonPredictionContext::create(config->context, ruleTransition->followState->stateNumber);
|
||||||
c = std::make_shared<LexerATNConfig>(config, t->target, newContext);
|
c = std::make_shared<LexerATNConfig>(config, t->target, newContext);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -426,13 +449,47 @@ LexerATNConfig::Ref LexerATNSimulator::getEpsilonTarget(CharStream *input, Lexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// ignore actions; just exec one per rule upon accept
|
|
||||||
case Transition::ACTION:
|
case Transition::ACTION:
|
||||||
c = std::make_shared<LexerATNConfig>(config, t->target, (static_cast<ActionTransition*>(t))->actionIndex);
|
if (config->context == nullptr|| config->context->hasEmptyPath()) {
|
||||||
|
// execute actions anywhere in the start rule for a token.
|
||||||
|
//
|
||||||
|
// TODO: if the entry rule is invoked recursively, some
|
||||||
|
// actions may be executed during the recursive call. The
|
||||||
|
// problem can appear when hasEmptyPath() is true but
|
||||||
|
// isEmpty() is false. In this case, the config needs to be
|
||||||
|
// split into two contexts - one with just the empty path
|
||||||
|
// and another with everything but the empty path.
|
||||||
|
// Unfortunately, the current algorithm does not allow
|
||||||
|
// getEpsilonTarget to return two configurations, so
|
||||||
|
// additional modifications are needed before we can support
|
||||||
|
// the split operation.
|
||||||
|
Ref<LexerActionExecutor> lexerActionExecutor = LexerActionExecutor::append(config->getLexerActionExecutor(),
|
||||||
|
atn.lexerActions[static_cast<ActionTransition *>(t)->actionIndex]);
|
||||||
|
c = std::make_shared<LexerATNConfig>(config, t->target, lexerActionExecutor);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// ignore actions in referenced rules
|
||||||
|
c = std::make_shared<LexerATNConfig>(config, t->target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case Transition::EPSILON:
|
case Transition::EPSILON:
|
||||||
c = std::make_shared<LexerATNConfig>(config, t->target);
|
c = std::make_shared<LexerATNConfig>(config, t->target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Transition::ATOM:
|
||||||
|
case Transition::RANGE:
|
||||||
|
case Transition::SET:
|
||||||
|
if (treatEofAsEpsilon) {
|
||||||
|
if (t->matches(EOF, Lexer::MIN_CHAR_VALUE, Lexer::MAX_CHAR_VALUE)) {
|
||||||
|
c = std::make_shared<LexerATNConfig>(config, t->target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
@ -465,13 +522,13 @@ bool LexerATNSimulator::evaluatePredicate(CharStream *input, int ruleIndex, int
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerATNSimulator::captureSimState(CharStream *input, dfa::DFAState *dfaState) {
|
void LexerATNSimulator::captureSimState(CharStream *input, dfa::DFAState *dfaState) {
|
||||||
prevAccept.index = (int)input->index();
|
_prevAccept.index = (int)input->index();
|
||||||
prevAccept.line = _line;
|
_prevAccept.line = _line;
|
||||||
prevAccept.charPos = _charPositionInLine;
|
_prevAccept.charPos = _charPositionInLine;
|
||||||
prevAccept.dfaState = dfaState;
|
_prevAccept.dfaState = dfaState;
|
||||||
}
|
}
|
||||||
|
|
||||||
dfa::DFAState *LexerATNSimulator::addDFAEdge(dfa::DFAState *from, ssize_t t, std::shared_ptr<ATNConfigSet> q) {
|
dfa::DFAState *LexerATNSimulator::addDFAEdge(dfa::DFAState *from, ssize_t t, Ref<ATNConfigSet> q) {
|
||||||
/* leading to this call, ATNConfigSet.hasSemanticContext is used as a
|
/* leading to this call, ATNConfigSet.hasSemanticContext is used as a
|
||||||
* marker indicating dynamic predicate evaluation makes this edge
|
* marker indicating dynamic predicate evaluation makes this edge
|
||||||
* dependent on the specific input sequence, so the static edge in the
|
* dependent on the specific input sequence, so the static edge in the
|
||||||
|
@ -514,14 +571,14 @@ void LexerATNSimulator::addDFAEdge(dfa::DFAState *p, ssize_t t, dfa::DFAState *q
|
||||||
p->edges[(size_t)(t - MIN_DFA_EDGE)] = q; // connect
|
p->edges[(size_t)(t - MIN_DFA_EDGE)] = q; // connect
|
||||||
}
|
}
|
||||||
|
|
||||||
dfa::DFAState *LexerATNSimulator::addDFAState(std::shared_ptr<ATNConfigSet> configs) {
|
dfa::DFAState *LexerATNSimulator::addDFAState(Ref<ATNConfigSet> configs) {
|
||||||
/* the lexer evaluates predicates on-the-fly; by this point configs
|
/* the lexer evaluates predicates on-the-fly; by this point configs
|
||||||
* should not contain any configurations with unevaluated predicates.
|
* should not contain any configurations with unevaluated predicates.
|
||||||
*/
|
*/
|
||||||
assert(!configs->hasSemanticContext);
|
assert(!configs->hasSemanticContext);
|
||||||
|
|
||||||
dfa::DFAState *proposed = new dfa::DFAState(configs); /* mem-check: managed by the DFA or deleted below */
|
dfa::DFAState *proposed = new dfa::DFAState(configs); /* mem-check: managed by the DFA or deleted below */
|
||||||
ATNConfig::Ref firstConfigWithRuleStopState = nullptr;
|
Ref<ATNConfig> firstConfigWithRuleStopState = nullptr;
|
||||||
for (auto c : configs->configs) {
|
for (auto c : configs->configs) {
|
||||||
if (is<RuleStopState*>(c->state)) {
|
if (is<RuleStopState*>(c->state)) {
|
||||||
firstConfigWithRuleStopState = c;
|
firstConfigWithRuleStopState = c;
|
||||||
|
@ -531,9 +588,8 @@ dfa::DFAState *LexerATNSimulator::addDFAState(std::shared_ptr<ATNConfigSet> conf
|
||||||
|
|
||||||
if (firstConfigWithRuleStopState != nullptr) {
|
if (firstConfigWithRuleStopState != nullptr) {
|
||||||
proposed->isAcceptState = true;
|
proposed->isAcceptState = true;
|
||||||
proposed->lexerRuleIndex = firstConfigWithRuleStopState->state->ruleIndex;
|
proposed->lexerActionExecutor = std::dynamic_pointer_cast<LexerATNConfig>(firstConfigWithRuleStopState)->getLexerActionExecutor();
|
||||||
proposed->lexerActionIndex = (std::static_pointer_cast<LexerATNConfig>(firstConfigWithRuleStopState))->lexerActionIndex;
|
proposed->prediction = atn.ruleToTokenType[firstConfigWithRuleStopState->state->ruleIndex];
|
||||||
proposed->prediction = atn.ruleToTokenType[(size_t)proposed->lexerRuleIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dfa::DFA &dfa = _decisionToDFA[_mode];
|
dfa::DFA &dfa = _decisionToDFA[_mode];
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "ATNSimulator.h"
|
#include "ATNSimulator.h"
|
||||||
#include "LexerATNConfig.h"
|
#include "LexerATNConfig.h"
|
||||||
|
#include "ATNConfigSet.h"
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -109,22 +110,23 @@ namespace atn {
|
||||||
protected:
|
protected:
|
||||||
size_t _mode;
|
size_t _mode;
|
||||||
|
|
||||||
/// <summary>
|
/// Used during DFA/ATN exec to record the most recent accept configuration info.
|
||||||
/// Used during DFA/ATN exec to record the most recent accept configuration info </summary>
|
SimState _prevAccept;
|
||||||
SimState prevAccept;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int match_calls;
|
static int match_calls;
|
||||||
|
|
||||||
LexerATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
LexerATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
||||||
std::shared_ptr<PredictionContextCache> sharedContextCache);
|
Ref<PredictionContextCache> sharedContextCache);
|
||||||
LexerATNSimulator(Lexer *recog, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
LexerATNSimulator(Lexer *recog, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
||||||
std::shared_ptr<PredictionContextCache> sharedContextCache);
|
Ref<PredictionContextCache> sharedContextCache);
|
||||||
|
|
||||||
virtual void copyState(LexerATNSimulator *simulator);
|
virtual void copyState(LexerATNSimulator *simulator);
|
||||||
virtual int match(CharStream *input, size_t mode);
|
virtual int match(CharStream *input, size_t mode);
|
||||||
virtual void reset() override;
|
virtual void reset() override;
|
||||||
|
|
||||||
|
virtual void clearDFA() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int matchATN(CharStream *input);
|
virtual int matchATN(CharStream *input);
|
||||||
virtual int execATN(CharStream *input, dfa::DFAState *ds0);
|
virtual int execATN(CharStream *input, dfa::DFAState *ds0);
|
||||||
|
@ -154,20 +156,22 @@ namespace atn {
|
||||||
/// returns <seealso cref="#ERROR"/>. </returns>
|
/// returns <seealso cref="#ERROR"/>. </returns>
|
||||||
virtual dfa::DFAState *computeTargetState(CharStream *input, dfa::DFAState *s, ssize_t t);
|
virtual dfa::DFAState *computeTargetState(CharStream *input, dfa::DFAState *s, ssize_t t);
|
||||||
|
|
||||||
virtual int failOrAccept(CharStream *input, std::shared_ptr<ATNConfigSet> reach, ssize_t t);
|
virtual int failOrAccept(CharStream *input, Ref<ATNConfigSet> reach, ssize_t t);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Given a starting configuration set, figure out all ATN configurations
|
/// Given a starting configuration set, figure out all ATN configurations
|
||||||
/// we can reach upon input {@code t}. Parameter {@code reach} is a return
|
/// we can reach upon input {@code t}. Parameter {@code reach} is a return
|
||||||
/// parameter.
|
/// parameter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void getReachableConfigSet(CharStream *input, std::shared_ptr<ATNConfigSet> closure, std::shared_ptr<ATNConfigSet> reach, ssize_t t);
|
void getReachableConfigSet(CharStream *input, Ref<ATNConfigSet> closure_, // closure_ as we have a closure() already
|
||||||
|
Ref<ATNConfigSet> reach, ssize_t t);
|
||||||
|
|
||||||
virtual void accept(CharStream *input, int ruleIndex, int actionIndex, size_t index, size_t line, size_t charPos);
|
virtual void accept(CharStream *input, Ref<LexerActionExecutor> lexerActionExecutor, int startIndex, size_t index,
|
||||||
|
size_t line, size_t charPos);
|
||||||
|
|
||||||
virtual ATNState *getReachableTarget(Transition *trans, ssize_t t);
|
virtual ATNState *getReachableTarget(Transition *trans, ssize_t t);
|
||||||
|
|
||||||
virtual std::shared_ptr<ATNConfigSet> computeStartState(CharStream *input, ATNState *p);
|
virtual Ref<ATNConfigSet> computeStartState(CharStream *input, ATNState *p);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Since the alternatives within any lexer decision are ordered by
|
/// Since the alternatives within any lexer decision are ordered by
|
||||||
|
@ -178,12 +182,12 @@ namespace atn {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns> {@code true} if an accept state is reached, otherwise
|
/// <returns> {@code true} if an accept state is reached, otherwise
|
||||||
/// {@code false}. </returns>
|
/// {@code false}. </returns>
|
||||||
virtual bool closure(CharStream *input, LexerATNConfig::Ref config, std::shared_ptr<ATNConfigSet> configs,
|
virtual bool closure(CharStream *input, Ref<LexerATNConfig> config, Ref<ATNConfigSet> configs,
|
||||||
bool currentAltReachedAcceptState, bool speculative);
|
bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon);
|
||||||
|
|
||||||
// side-effect: can alter configs.hasSemanticContext
|
// side-effect: can alter configs.hasSemanticContext
|
||||||
virtual LexerATNConfig::Ref getEpsilonTarget(CharStream *input, LexerATNConfig::Ref config, Transition *t,
|
virtual Ref<LexerATNConfig> getEpsilonTarget(CharStream *input, Ref<LexerATNConfig> config, Transition *t,
|
||||||
std::shared_ptr<ATNConfigSet> configs, bool speculative);
|
Ref<ATNConfigSet> configs, bool speculative, bool treatEofAsEpsilon);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Evaluate a predicate specified in the lexer.
|
/// Evaluate a predicate specified in the lexer.
|
||||||
|
@ -208,7 +212,7 @@ namespace atn {
|
||||||
virtual bool evaluatePredicate(CharStream *input, int ruleIndex, int predIndex, bool speculative);
|
virtual bool evaluatePredicate(CharStream *input, int ruleIndex, int predIndex, bool speculative);
|
||||||
|
|
||||||
virtual void captureSimState(CharStream *input, dfa::DFAState *dfaState);
|
virtual void captureSimState(CharStream *input, dfa::DFAState *dfaState);
|
||||||
virtual dfa::DFAState *addDFAEdge(dfa::DFAState *from, ssize_t t, std::shared_ptr<ATNConfigSet> q);
|
virtual dfa::DFAState* addDFAEdge(dfa::DFAState *from, ssize_t t, Ref<ATNConfigSet> q);
|
||||||
virtual void addDFAEdge(dfa::DFAState *p, ssize_t t, dfa::DFAState *q);
|
virtual void addDFAEdge(dfa::DFAState *p, ssize_t t, dfa::DFAState *q);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -217,7 +221,7 @@ namespace atn {
|
||||||
/// configuration containing an ATN rule stop state. Later, when
|
/// configuration containing an ATN rule stop state. Later, when
|
||||||
/// traversing the DFA, we will know which rule to accept.
|
/// traversing the DFA, we will know which rule to accept.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual dfa::DFAState *addDFAState(std::shared_ptr<ATNConfigSet> configs);
|
virtual dfa::DFAState *addDFAState(Ref<ATNConfigSet> configs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dfa::DFA& getDFA(size_t mode);
|
dfa::DFA& getDFA(size_t mode);
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "LexerActionType.h"
|
#include "LexerActionType.h"
|
||||||
#include "Lexer.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -50,8 +49,6 @@ namespace atn {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class LexerAction {
|
class LexerAction {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<LexerAction> Ref;
|
|
||||||
|
|
||||||
virtual ~LexerAction() {};
|
virtual ~LexerAction() {};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -82,7 +79,7 @@ namespace atn {
|
||||||
/// positioned correctly prior to calling this method.</para>
|
/// positioned correctly prior to calling this method.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="lexer"> The lexer instance. </param>
|
/// <param name="lexer"> The lexer instance. </param>
|
||||||
virtual void execute(Lexer::Ref lexer) = 0;
|
virtual void execute(Lexer *lexer) = 0;
|
||||||
|
|
||||||
virtual size_t hashCode() const = 0;
|
virtual size_t hashCode() const = 0;
|
||||||
virtual bool operator == (const LexerAction &obj) const = 0;
|
virtual bool operator == (const LexerAction &obj) const = 0;
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "MurmurHash.h"
|
||||||
|
#include "LexerIndexedCustomAction.h"
|
||||||
|
#include "CPPUtils.h"
|
||||||
|
#include "Arrays.h"
|
||||||
|
|
||||||
|
#include "LexerActionExecutor.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
using namespace org::antlr::v4::runtime::misc;
|
||||||
|
using namespace antlrcpp;
|
||||||
|
|
||||||
|
LexerActionExecutor::LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions)
|
||||||
|
: _lexerActions(lexerActions), _hashCode(generateHashCode()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<LexerActionExecutor> LexerActionExecutor::append(Ref<LexerActionExecutor> lexerActionExecutor, Ref<LexerAction> lexerAction) {
|
||||||
|
if (lexerActionExecutor == nullptr) {
|
||||||
|
return std::make_shared<LexerActionExecutor>(std::vector<Ref<LexerAction>> { lexerAction });
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Ref<LexerAction>> lexerActions = lexerActionExecutor->_lexerActions; // Make a copy.
|
||||||
|
lexerActions.push_back(lexerAction);
|
||||||
|
return std::make_shared<LexerActionExecutor>(lexerActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<LexerActionExecutor> LexerActionExecutor::fixOffsetBeforeMatch(int offset) {
|
||||||
|
std::vector<Ref<LexerAction>> updatedLexerActions;
|
||||||
|
for (size_t i = 0; i < _lexerActions.size(); i++) {
|
||||||
|
if (_lexerActions[i]->isPositionDependent() && !is<LexerIndexedCustomAction>(_lexerActions[i])) {
|
||||||
|
if (updatedLexerActions.empty()) {
|
||||||
|
updatedLexerActions = _lexerActions; // Make a copy.
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedLexerActions[i] = std::make_shared<LexerIndexedCustomAction>(offset, _lexerActions[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updatedLexerActions.empty()) {
|
||||||
|
return shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_shared<LexerActionExecutor>(updatedLexerActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Ref<LexerAction>> LexerActionExecutor::getLexerActions() const {
|
||||||
|
return _lexerActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LexerActionExecutor::execute(Lexer *lexer, CharStream *input, int startIndex) {
|
||||||
|
bool requiresSeek = false;
|
||||||
|
size_t stopIndex = input->index();
|
||||||
|
|
||||||
|
auto onExit = finally([requiresSeek, input, stopIndex]() {
|
||||||
|
if (requiresSeek) {
|
||||||
|
input->seek(stopIndex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (auto lexerAction : _lexerActions) {
|
||||||
|
if (is<LexerIndexedCustomAction>(lexerAction)) {
|
||||||
|
int offset = (std::static_pointer_cast<LexerIndexedCustomAction>(lexerAction))->getOffset();
|
||||||
|
input->seek(startIndex + offset);
|
||||||
|
lexerAction = std::static_pointer_cast<LexerIndexedCustomAction>(lexerAction)->getAction();
|
||||||
|
requiresSeek = (size_t)(startIndex + offset) != stopIndex;
|
||||||
|
} else if (lexerAction->isPositionDependent()) {
|
||||||
|
input->seek(stopIndex);
|
||||||
|
requiresSeek = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lexerAction->execute(lexer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t LexerActionExecutor::hashCode() const {
|
||||||
|
return _hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LexerActionExecutor::operator == (const LexerActionExecutor &obj) const {
|
||||||
|
if (&obj == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _hashCode == obj._hashCode && Arrays::equals(_lexerActions, obj._lexerActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t LexerActionExecutor::generateHashCode() const {
|
||||||
|
size_t hash = MurmurHash::initialize();
|
||||||
|
for (auto lexerAction : _lexerActions) {
|
||||||
|
hash = MurmurHash::update(hash, (size_t)lexerAction.get());
|
||||||
|
}
|
||||||
|
MurmurHash::finish(hash, _lexerActions.size());
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CharStream.h"
|
||||||
|
#include "LexerAction.h"
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace atn {
|
||||||
|
|
||||||
|
/// Represents an executor for a sequence of lexer actions which traversed during
|
||||||
|
/// the matching operation of a lexer rule (token).
|
||||||
|
///
|
||||||
|
/// <para>The executor tracks position information for position-dependent lexer actions
|
||||||
|
/// efficiently, ensuring that actions appearing only at the end of the rule do
|
||||||
|
/// not cause bloating of the <seealso cref="DFA"/> created for the lexer.</para>
|
||||||
|
class LexerActionExecutor : public std::enable_shared_from_this<LexerActionExecutor> {
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary>
|
||||||
|
/// <param name="lexerActions"> The lexer actions to execute. </param>
|
||||||
|
LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for
|
||||||
|
/// the input {@code lexerActionExecutor} followed by a specified
|
||||||
|
/// {@code lexerAction}.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lexerActionExecutor"> The executor for actions already traversed by
|
||||||
|
/// the lexer while matching a token within a particular
|
||||||
|
/// <seealso cref="LexerATNConfig"/>. If this is {@code null}, the method behaves as
|
||||||
|
/// though it were an empty executor. </param>
|
||||||
|
/// <param name="lexerAction"> The lexer action to execute after the actions
|
||||||
|
/// specified in {@code lexerActionExecutor}.
|
||||||
|
/// </param>
|
||||||
|
/// <returns> A <seealso cref="LexerActionExecutor"/> for executing the combine actions
|
||||||
|
/// of {@code lexerActionExecutor} and {@code lexerAction}. </returns>
|
||||||
|
static Ref<LexerActionExecutor> append(Ref<LexerActionExecutor> lexerActionExecutor, const Ref<LexerAction> lexerAction);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <seealso cref="LexerActionExecutor"/> which encodes the current offset
|
||||||
|
/// for position-dependent lexer actions.
|
||||||
|
///
|
||||||
|
/// <para>Normally, when the executor encounters lexer actions where
|
||||||
|
/// <seealso cref="LexerAction#isPositionDependent"/> returns {@code true}, it calls
|
||||||
|
/// <seealso cref="IntStream#seek"/> on the input <seealso cref="CharStream"/> to set the input
|
||||||
|
/// position to the <em>end</em> of the current token. This behavior provides
|
||||||
|
/// for efficient DFA representation of lexer actions which appear at the end
|
||||||
|
/// of a lexer rule, even when the lexer rule matches a variable number of
|
||||||
|
/// characters.</para>
|
||||||
|
///
|
||||||
|
/// <para>Prior to traversing a match transition in the ATN, the current offset
|
||||||
|
/// from the token start index is assigned to all position-dependent lexer
|
||||||
|
/// actions which have not already been assigned a fixed offset. By storing
|
||||||
|
/// the offsets relative to the token start index, the DFA representation of
|
||||||
|
/// lexer actions which appear in the middle of tokens remains efficient due
|
||||||
|
/// to sharing among tokens of the same length, regardless of their absolute
|
||||||
|
/// position in the input stream.</para>
|
||||||
|
///
|
||||||
|
/// <para>If the current executor already has offsets assigned to all
|
||||||
|
/// position-dependent lexer actions, the method returns {@code this}.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset"> The current offset to assign to all position-dependent
|
||||||
|
/// lexer actions which do not already have offsets assigned.
|
||||||
|
/// </param>
|
||||||
|
/// <returns> A <seealso cref="LexerActionExecutor"/> which stores input stream offsets
|
||||||
|
/// for all position-dependent lexer actions. </returns>
|
||||||
|
virtual Ref<LexerActionExecutor> fixOffsetBeforeMatch(int offset);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the lexer actions to be executed by this executor. </summary>
|
||||||
|
/// <returns> The lexer actions to be executed by this executor. </returns>
|
||||||
|
virtual std::vector<Ref<LexerAction>> getLexerActions() const;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute the actions encapsulated by this executor within the context of a
|
||||||
|
/// particular <seealso cref="Lexer"/>.
|
||||||
|
///
|
||||||
|
/// <para>This method calls <seealso cref="IntStream#seek"/> to set the position of the
|
||||||
|
/// {@code input} <seealso cref="CharStream"/> prior to calling
|
||||||
|
/// <seealso cref="LexerAction#execute"/> on a position-dependent action. Before the
|
||||||
|
/// method returns, the input position will be restored to the same position
|
||||||
|
/// it was in when the method was invoked.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lexer"> The lexer instance. </param>
|
||||||
|
/// <param name="input"> The input stream which is the source for the current token.
|
||||||
|
/// When this method is called, the current <seealso cref="IntStream#index"/> for
|
||||||
|
/// {@code input} should be the start of the following token, i.e. 1
|
||||||
|
/// character past the end of the current token. </param>
|
||||||
|
/// <param name="startIndex"> The token start index. This value may be passed to
|
||||||
|
/// <seealso cref="IntStream#seek"/> to set the {@code input} position to the beginning
|
||||||
|
/// of the token. </param>
|
||||||
|
virtual void execute(Lexer *lexer, CharStream *input, int startIndex);
|
||||||
|
|
||||||
|
virtual size_t hashCode() const;
|
||||||
|
virtual bool operator == (const LexerActionExecutor &obj) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::vector<Ref<LexerAction>> _lexerActions;
|
||||||
|
|
||||||
|
/// Caches the result of <seealso cref="#hashCode"/> since the hash code is an element
|
||||||
|
/// of the performance-critical <seealso cref="LexerATNConfig#hashCode"/> operation.
|
||||||
|
const size_t _hashCode;
|
||||||
|
|
||||||
|
size_t generateHashCode() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
|
@ -30,6 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MurmurHash.h"
|
#include "MurmurHash.h"
|
||||||
|
#include "Lexer.h"
|
||||||
|
|
||||||
#include "LexerChannelAction.h"
|
#include "LexerChannelAction.h"
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ bool LexerChannelAction::isPositionDependent() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerChannelAction::execute(Lexer::Ref lexer) {
|
void LexerChannelAction::execute(Lexer *lexer) {
|
||||||
lexer->setChannel(_channel);
|
lexer->setChannel(_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace atn {
|
||||||
/// <para>This action is implemented by calling <seealso cref="Lexer#setChannel"/> with the
|
/// <para>This action is implemented by calling <seealso cref="Lexer#setChannel"/> with the
|
||||||
/// value provided by <seealso cref="#getChannel"/>.</para>
|
/// value provided by <seealso cref="#getChannel"/>.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void execute(Lexer::Ref lexer) override;
|
virtual void execute(Lexer *lexer) override;
|
||||||
|
|
||||||
virtual size_t hashCode() const override;
|
virtual size_t hashCode() const override;
|
||||||
virtual bool operator == (const LexerAction &obj) const override;
|
virtual bool operator == (const LexerAction &obj) const override;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "MurmurHash.h"
|
#include "MurmurHash.h"
|
||||||
#include "CPPUtils.h"
|
#include "CPPUtils.h"
|
||||||
|
#include "Lexer.h"
|
||||||
|
|
||||||
#include "LexerCustomAction.h"
|
#include "LexerCustomAction.h"
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ bool LexerCustomAction::isPositionDependent() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerCustomAction::execute(Lexer::Ref lexer) {
|
void LexerCustomAction::execute(Lexer *lexer) {
|
||||||
lexer->action(nullptr, _ruleIndex, _actionIndex);
|
lexer->action(nullptr, _ruleIndex, _actionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
#include "LexerAction.h"
|
#include "LexerAction.h"
|
||||||
#include "LexerActionType.h"
|
#include "LexerActionType.h"
|
||||||
#include "Lexer.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -102,7 +101,7 @@ namespace atn {
|
||||||
/// <para>Custom actions are implemented by calling <seealso cref="Lexer#action"/> with the
|
/// <para>Custom actions are implemented by calling <seealso cref="Lexer#action"/> with the
|
||||||
/// appropriate rule and action indexes.</para>
|
/// appropriate rule and action indexes.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void execute(Lexer::Ref lexer) override;
|
virtual void execute(Lexer *lexer) override;
|
||||||
|
|
||||||
virtual size_t hashCode() const override;
|
virtual size_t hashCode() const override;
|
||||||
virtual bool operator == (const LexerAction &obj) const override;
|
virtual bool operator == (const LexerAction &obj) const override;
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "MurmurHash.h"
|
||||||
|
#include "Lexer.h"
|
||||||
|
#include "CPPUtils.h"
|
||||||
|
|
||||||
|
#include "LexerIndexedCustomAction.h"
|
||||||
|
|
||||||
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
|
using namespace org::antlr::v4::runtime::misc;
|
||||||
|
|
||||||
|
LexerIndexedCustomAction::LexerIndexedCustomAction(int offset, Ref<LexerAction> action) : _offset(offset), _action(action) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int LexerIndexedCustomAction::getOffset() const {
|
||||||
|
return _offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<LexerAction> LexerIndexedCustomAction::getAction() const {
|
||||||
|
return _action;
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerActionType LexerIndexedCustomAction::getActionType() const {
|
||||||
|
return _action->getActionType();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LexerIndexedCustomAction::isPositionDependent() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LexerIndexedCustomAction::execute(Lexer *lexer) {
|
||||||
|
// assume the input stream position was properly set by the calling code
|
||||||
|
_action->execute(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t LexerIndexedCustomAction::hashCode() const {
|
||||||
|
size_t hash = MurmurHash::initialize();
|
||||||
|
hash = MurmurHash::update(hash, _offset);
|
||||||
|
hash = MurmurHash::update(hash, (size_t)_action.get());
|
||||||
|
return MurmurHash::finish(hash, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LexerIndexedCustomAction::operator == (const LexerAction &obj) const {
|
||||||
|
if (&obj == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LexerIndexedCustomAction *action = dynamic_cast<const LexerIndexedCustomAction *>(&obj);
|
||||||
|
if (action == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _offset == action->_offset && _action == action->_action;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring LexerIndexedCustomAction::toString() const {
|
||||||
|
return antlrcpp::toString(this);
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* [The "BSD license"]
|
||||||
|
* Copyright (c) 2016 Mike Lischke
|
||||||
|
* Copyright (c) 2014 Terence Parr
|
||||||
|
* Copyright (c) 2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "RuleContext.h"
|
||||||
|
#include "LexerAction.h"
|
||||||
|
|
||||||
|
namespace org {
|
||||||
|
namespace antlr {
|
||||||
|
namespace v4 {
|
||||||
|
namespace runtime {
|
||||||
|
namespace atn {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This implementation of <seealso cref="LexerAction"/> is used for tracking input offsets
|
||||||
|
/// for position-dependent actions within a <seealso cref="LexerActionExecutor"/>.
|
||||||
|
///
|
||||||
|
/// <para>This action is not serialized as part of the ATN, and is only required for
|
||||||
|
/// position-dependent lexer actions which appear at a location other than the
|
||||||
|
/// end of a rule. For more information about DFA optimizations employed for
|
||||||
|
/// lexer actions, see <seealso cref="LexerActionExecutor#append"/> and
|
||||||
|
/// <seealso cref="LexerActionExecutor#fixOffsetBeforeMatch"/>.</para>
|
||||||
|
///
|
||||||
|
/// @author Sam Harwell
|
||||||
|
/// @since 4.2
|
||||||
|
/// </summary>
|
||||||
|
class LexerIndexedCustomAction final : public LexerAction {
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new indexed custom action by associating a character offset
|
||||||
|
/// with a <seealso cref="LexerAction"/>.
|
||||||
|
///
|
||||||
|
/// <para>Note: This class is only required for lexer actions for which
|
||||||
|
/// <seealso cref="LexerAction#isPositionDependent"/> returns {@code true}.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset"> The offset into the input <seealso cref="CharStream"/>, relative to
|
||||||
|
/// the token start index, at which the specified lexer action should be
|
||||||
|
/// executed. </param>
|
||||||
|
/// <param name="action"> The lexer action to execute at a particular offset in the
|
||||||
|
/// input <seealso cref="CharStream"/>. </param>
|
||||||
|
LexerIndexedCustomAction(int offset, Ref<LexerAction> action);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the location in the input <seealso cref="CharStream"/> at which the lexer
|
||||||
|
/// action should be executed. The value is interpreted as an offset relative
|
||||||
|
/// to the token start index.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns> The location in the input <seealso cref="CharStream"/> at which the lexer
|
||||||
|
/// action should be executed. </returns>
|
||||||
|
int getOffset() const;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the lexer action to execute.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns> A <seealso cref="LexerAction"/> object which executes the lexer action. </returns>
|
||||||
|
Ref<LexerAction> getAction() const;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// {@inheritDoc}
|
||||||
|
/// </summary>
|
||||||
|
/// <returns> This method returns the result of calling <seealso cref="#getActionType"/>
|
||||||
|
/// on the <seealso cref="LexerAction"/> returned by <seealso cref="#getAction"/>. </returns>
|
||||||
|
virtual LexerActionType getActionType() const override;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// {@inheritDoc} </summary>
|
||||||
|
/// <returns> This method returns {@code true}. </returns>
|
||||||
|
virtual bool isPositionDependent() const override;
|
||||||
|
|
||||||
|
virtual void execute(Lexer *lexer) override;
|
||||||
|
virtual size_t hashCode() const override;
|
||||||
|
virtual bool operator == (const LexerAction &obj) const override;
|
||||||
|
virtual std::wstring toString() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const int _offset;
|
||||||
|
const Ref<LexerAction> _action;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atn
|
||||||
|
} // namespace runtime
|
||||||
|
} // namespace v4
|
||||||
|
} // namespace antlr
|
||||||
|
} // namespace org
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MurmurHash.h"
|
#include "MurmurHash.h"
|
||||||
|
#include "Lexer.h"
|
||||||
|
|
||||||
#include "LexerModeAction.h"
|
#include "LexerModeAction.h"
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ bool LexerModeAction::isPositionDependent() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerModeAction::execute(Lexer::Ref lexer) {
|
void LexerModeAction::execute(Lexer *lexer) {
|
||||||
lexer->mode(_mode);
|
lexer->mode(_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
#include "LexerAction.h"
|
#include "LexerAction.h"
|
||||||
#include "LexerActionType.h"
|
#include "LexerActionType.h"
|
||||||
#include "Lexer.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -77,7 +76,7 @@ namespace atn {
|
||||||
/// <para>This action is implemented by calling <seealso cref="Lexer#mode"/> with the
|
/// <para>This action is implemented by calling <seealso cref="Lexer#mode"/> with the
|
||||||
/// value provided by <seealso cref="#getMode"/>.</para>
|
/// value provided by <seealso cref="#getMode"/>.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void execute(Lexer::Ref lexer) override;
|
virtual void execute(Lexer *lexer) override;
|
||||||
|
|
||||||
virtual size_t hashCode() const override;
|
virtual size_t hashCode() const override;
|
||||||
virtual bool operator == (const LexerAction &obj) const override;
|
virtual bool operator == (const LexerAction &obj) const override;
|
||||||
|
|
|
@ -30,13 +30,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MurmurHash.h"
|
#include "MurmurHash.h"
|
||||||
|
#include "Lexer.h"
|
||||||
|
|
||||||
#include "LexerMoreAction.h"
|
#include "LexerMoreAction.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime::atn;
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
using namespace org::antlr::v4::runtime::misc;
|
using namespace org::antlr::v4::runtime::misc;
|
||||||
|
|
||||||
const std::shared_ptr<LexerMoreAction> LexerMoreAction::INSTANCE { new LexerMoreAction() };
|
const Ref<LexerMoreAction> LexerMoreAction::INSTANCE { new LexerMoreAction() };
|
||||||
|
|
||||||
LexerMoreAction::LexerMoreAction() {
|
LexerMoreAction::LexerMoreAction() {
|
||||||
}
|
}
|
||||||
|
@ -49,7 +50,7 @@ bool LexerMoreAction::isPositionDependent() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerMoreAction::execute(Lexer::Ref lexer) {
|
void LexerMoreAction::execute(Lexer *lexer) {
|
||||||
lexer->more();
|
lexer->more();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
#include "LexerAction.h"
|
#include "LexerAction.h"
|
||||||
#include "LexerActionType.h"
|
#include "LexerActionType.h"
|
||||||
#include "Lexer.h"
|
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
namespace antlr {
|
namespace antlr {
|
||||||
|
@ -55,7 +54,7 @@ namespace atn {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides a singleton instance of this parameterless lexer action.
|
/// Provides a singleton instance of this parameterless lexer action.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static const std::shared_ptr<LexerMoreAction> INSTANCE;
|
static const Ref<LexerMoreAction> INSTANCE;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// {@inheritDoc} </summary>
|
/// {@inheritDoc} </summary>
|
||||||
|
@ -72,7 +71,7 @@ namespace atn {
|
||||||
///
|
///
|
||||||
/// <para>This action is implemented by calling <seealso cref="Lexer#more"/>.</para>
|
/// <para>This action is implemented by calling <seealso cref="Lexer#more"/>.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void execute(Lexer::Ref lexer) override;
|
virtual void execute(Lexer *lexer) override;
|
||||||
|
|
||||||
virtual size_t hashCode() const override;
|
virtual size_t hashCode() const override;
|
||||||
virtual bool operator == (const LexerAction &obj) const override;
|
virtual bool operator == (const LexerAction &obj) const override;
|
||||||
|
|
|
@ -30,12 +30,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MurmurHash.h"
|
#include "MurmurHash.h"
|
||||||
|
#include "Lexer.h"
|
||||||
|
|
||||||
#include "LexerPopModeAction.h"
|
#include "LexerPopModeAction.h"
|
||||||
|
|
||||||
using namespace org::antlr::v4::runtime::atn;
|
using namespace org::antlr::v4::runtime::atn;
|
||||||
using namespace org::antlr::v4::runtime::misc;
|
using namespace org::antlr::v4::runtime::misc;
|
||||||
|
|
||||||
const std::shared_ptr<LexerPopModeAction> LexerPopModeAction::INSTANCE { new LexerPopModeAction() };
|
const Ref<LexerPopModeAction> LexerPopModeAction::INSTANCE { new LexerPopModeAction() };
|
||||||
|
|
||||||
LexerPopModeAction::LexerPopModeAction() {
|
LexerPopModeAction::LexerPopModeAction() {
|
||||||
}
|
}
|
||||||
|
@ -48,7 +50,7 @@ bool LexerPopModeAction::isPositionDependent() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LexerPopModeAction::execute(Lexer::Ref lexer) {
|
void LexerPopModeAction::execute(Lexer *lexer) {
|
||||||
lexer->popMode();
|
lexer->popMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue