-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCminusParserDriver.cpp
53 lines (39 loc) · 1.36 KB
/
CminusParserDriver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// Created by Nathaniel Rupprecht on 2/25/24.
//
#include "manta/generatedparsers/CminusParser.h"
#include <Lightning/Lightning.h>
#include "manta/utility/Timer.h"
using namespace lightning;
auto main() -> int {
/*
* Application to run the Manta generated "C- language" parser.
*
* I found the C- language at http://marvin.cs.uidaho.edu/Teaching/CS445/ and thought it would be a really
* good test case since it is not at all a trivial language, but it also lacks the complexity of e.g. a full
* C++ parser, which is not even a context free grammar, and does not require indentation based parsing like
* Python.
*
*/
Global::GetCore()->AddSink(NewSink<StdoutSink>());
Logger logger;
logger.GetCore()->AddSink(NewSink<StdoutSink>());
#ifdef MANTA_PARSER_GENERATED
Parser parser;
parser.SetLogger(logger);
parser.SetInput(manta::utility::IStreamContainer::OpenFile("../../examples/C-/C- code.cmm"));
manta::utility::Timer timer {};
std::shared_ptr<ASTNodeBase> node {};
try {
node = parser.ParseInput();
} catch (const std::exception& ex) {
LOG_SEV_TO(logger, Fatal) << "Exception caught: " << ex.what();
return 1;
}
timer.Stop();
LOG_SEV_TO(logger, Info) << "Parse took " << timer.Time() << " seconds.";
// PrintingVisitor visitor;
// node->Accept(visitor);
#endif // MANTA_PARSER_GENERATED
return 0;
}