-
-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (31 loc) · 849 Bytes
/
main.cpp
File metadata and controls
39 lines (31 loc) · 849 Bytes
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
/*
Build a "static" lexer in release builds.
Static in the sense that the state machine is built in a pre-build
step to optimize application start-up time.
*/
#include <pl/core/lexer_sm.hpp>
#include <lexertl/state_machine.hpp>
#include <lexertl/generate_cpp.hpp>
#include <fstream>
#include <filesystem>
int main(int argc, char *argv[])
{
if (argc!=2)
return 1;
try
{
std::filesystem::path argPath(argv[1]);
std::filesystem::path genDir = argPath.parent_path();
std::filesystem::create_directory(genDir);
}
catch (const std::filesystem::filesystem_error &fse)
{
return 1;
}
lexertl::state_machine sm;
pl::core::newLexerBuild(sm);
sm.minimise();
std::ofstream ofs(argv[1]);
lexertl::table_based_cpp::generate("lookup", sm, false, ofs);
return 0;
}