-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMDXtoHTML.cpp
64 lines (50 loc) · 1.41 KB
/
MDXtoHTML.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
54
55
56
57
58
59
60
61
62
63
64
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#define __DBGOUTPUT__
#include "service.h"
#include "MDXparser.h"
#include "Utils.h"
#include "Compiler.h"
using namespace std;
int main( int argc, char* argv[] )
{
setlocale(0, ""); // setlocale(LC_CTYPE, "");
// Ôàéëû ñ êîòîðûìè ìû áóäåì ðàáîòàòü.
ifstream input_file;
ofstream output_file;
/**
* Ñîáèðàåì ïåðåäàííûå íàì ïàðàìåòðû è îòêðûâàåì ôàéëû äëÿ ðàáîòû.
* Åñëè ÷òî-òî íå óäàëîñü ñäåëàòü, òî ôóíêöèÿ âûâåäåò îøèáêó, à ìû çàêîí÷èì âûïîëíåíèå.
*/
if ( !readConsoleParams( argc, argv, input_file, output_file ) )
{
return 0;
}
// Äàííûå äëÿ ëåêñåðà ïîêà òóò. Íóæíî áóäåò êóäà-íèáóäü çàñóíóòü äëÿ óäîáíîãî èçìåíåíèÿ
string res_words[] = { "reserve" };
string structures[] = { "Def:", "Ex:", "Thm:", "Proof:", "Note:", "Comment:", "Task:", "Table:", "#", "##", "###", "####", "######", "+", "---", "*", "**" };
string deviders[] = { " ", "\n", "\t"}; // "{", "}",
// Çàïóñêàåì ëåêñè÷åñêèé àíàëèçàòîð
Lexer lex;
lex.Init( res_words, 1, structures, 17, deviders, 3 );
string text;
while ( !input_file.eof() )
{
string buf;
getline(input_file, buf);
text+= buf + "\n";
}
#ifdef __DBGOUTPUT__
MACRO_MESSAGE("\n---text:---\n" + text);
#endif
lex.lex(text);
lex.save_tokens();
Compiler compiler;
compiler.load_tokens( lex.get_tokens() );
compiler.compile();
output_file<<compiler;
system("pause");
return 0;
}