]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/demo/Windows/antlr4-cpp-demo/main.cpp
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / demo / Windows / antlr4-cpp-demo / main.cpp
1 ๏ปฟ/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5
6 //
7 //  main.cpp
8 //  antlr4-cpp-demo
9 //
10 //  Created by Mike Lischke on 13.03.16.
11 //
12
13 #include <iostream>
14
15 #include "antlr4-runtime.h"
16 #include "TLexer.h"
17 #include "TParser.h"
18
19 #include <Windows.h>
20
21 #pragma execution_character_set("utf-8")
22
23 using namespace antlrcpptest;
24 using namespace antlr4;
25
26 int main(int argc, const char * argv[]) {
27
28   ANTLRInputStream input("๐Ÿด = ๐Ÿ + \"๐Ÿ˜Ž\";(((x * ฯ€))) * ยต + โˆฐ; a + (x * (y ? 0 : 1) + z);");
29   TLexer lexer(&input);
30   CommonTokenStream tokens(&lexer);
31
32   TParser parser(&tokens);
33   tree::ParseTree *tree = parser.main();
34
35   std::wstring s = antlrcpp::s2ws(tree->toStringTree(&parser)) + L"\n";
36
37   OutputDebugString(s.data()); // Only works properly since VS 2015.
38   //std::wcout << "Parse Tree: " << s << std::endl; Unicode output in the console is very limited.
39
40   return 0;
41 }