Skip to content

Commit d5cb24c

Browse files
committed
WIP:有减号问题,要移到语法上做
1 parent dcd46bf commit d5cb24c

File tree

5 files changed

+85
-25
lines changed

5 files changed

+85
-25
lines changed

CMakeLists.txt

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
99
find_package(LLVM REQUIRED CONFIG)
1010
include_directories(${LLVM_INCLUDE_DIRS})
1111
add_definitions(${LLVM_DEFINITIONS})
12+
message(STATUS "Found llvm in ${LLVM_INCLUDE_DIRS}")
1213

1314
find_package(Clang REQUIRED CONFIG)
1415
include_directories(${CLANG_INCLUDE_DIRS})
@@ -25,11 +26,11 @@ find_package(Boost COMPONENTS system filesystem thread chrono REQUIRED)
2526
include_directories(${Boost_INCLUDE_DIR})
2627
link_directories(${Boost_LIBRARY_DIR})
2728

28-
#find_package(PkgConfig REQUIRED)
29-
#pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
30-
#include_directories(${GTK3_INCLUDE_DIRS})
31-
#link_directories(${GTK3_LIBRARY_DIRS})
32-
#add_definitions(${GTK3_CFLAGS_OTHER})
29+
find_package(PkgConfig REQUIRED)
30+
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
31+
include_directories(${GTK3_INCLUDE_DIRS})
32+
link_directories(${GTK3_LIBRARY_DIRS})
33+
add_definitions(${GTK3_CFLAGS_OTHER})
3334
# 处理语法分析器
3435
#find_package(BISON)
3536
#BISON_TARGET(Parser parser/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser/Parser.cpp
@@ -39,9 +40,9 @@ link_directories(${Boost_LIBRARY_DIR})
3940
#set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
4041

4142
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
42-
#message(STATUS "GTK3_INCLUDE_DIRS: ${GTK3_INCLUDE_DIRS}")
43-
#message(STATUS "GKT3_LIBRARIES: ${GTK3_LIBRARIES}")
44-
#message(STATUS "GTK3_LINK_LIBRARIES: ${GTK3_LINK_LIBRARIES}")
43+
message(STATUS "GTK3_INCLUDE_DIRS: ${GTK3_INCLUDE_DIRS}")
44+
message(STATUS "GKT3_LIBRARIES: ${GTK3_LIBRARIES}")
45+
message(STATUS "GTK3_LINK_LIBRARIES: ${GTK3_LINK_LIBRARIES}")
4546
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
4647
message(STATUS "Using defs in: ${LLVM_DEFINITIONS}")
4748
message(STATUS "CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}")
@@ -135,19 +136,29 @@ message(STATUS "Found ${llvm_libs}")
135136

136137
# Link against LLVM libraries
137138
#target_link_libraries(sysyplus_compiler ${llvm_libs})
138-
target_link_libraries(sysyplus_compiler
139-
LLVM
140-
${GTKMM_LIBRARIES}
141-
Boost::thread Boost::chrono
142-
clangDriver
143-
)
139+
if(WIN32)
140+
target_link_libraries(sysyplus_compiler
141+
LLVM
142+
${GTKMM_LIBRARIES}
143+
Boost::thread Boost::chrono
144+
clangDriver
145+
wsock32
146+
)
147+
else()
148+
target_link_libraries(sysyplus_compiler
149+
LLVM
150+
${GTKMM_LIBRARIES}
151+
Boost::thread Boost::chrono
152+
clangDriver
153+
)
154+
endif()
144155

145156
#message(STATUS "UI逻辑:复制UI:${CMAKE_SOURCE_DIR}/ui/ui -> ${CMAKE_CURRENT_BINARY_DIR}/ui")
146157
#add_custom_command(TARGET sysyplus_compiler PRE_BUILD
147158
# COMMAND ${CMAKE_COMMAND} -E copy_directory
148159
# ${CMAKE_SOURCE_DIR}/ui/ui ${CMAKE_CURRENT_BINARY_DIR}/ui)
149160

150-
#message(STATUS "配置目标库")
161+
message(STATUS "配置目标库")
151162
#add_subdirectory(module)
152163

153164
# time module

ast/NodeAST.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ enum ASTType {
2222
};
2323

2424
enum VarType {
25-
INT,
26-
VOID
25+
SYSY_INT,
26+
SYSY_VOID
2727
};
2828

2929
enum BinaryType {

module/web/src/web.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
#include <boost/bind.hpp>
1313
#include <boost/asio.hpp>
1414
#include <boost/asio/ssl.hpp>
15-
15+
#ifdef _WIN32
16+
#include <direct.h>
17+
#define getcwd _getcwd // stupid MSFT "deprecation" warning
18+
#elif
19+
#include <unistd.h>
20+
#endif
1621
//#include <>
1722

1823
/// 客户端状态码

parser/Lexer.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ int Lexer::_getNextToken() {
137137
identifierStr = char(last_char);
138138

139139

140-
while (ispunct((last_char = getchar()))) {
140+
while (ispunct((seek()))) {
141+
NEXTCHAR;
141142
identifierStr += last_char;
142143
// 注释
143144
if (identifierStr == "//") {
@@ -147,17 +148,20 @@ int Lexer::_getNextToken() {
147148
NEXTCHAR;
148149
return _getNextToken();
149150
}
151+
else if (identifierStr == "&&") {
152+
NEXTCHAR;
153+
return T_AND;
154+
}
155+
else if (identifierStr == "||") {
156+
NEXTCHAR;
157+
return T_OR;
158+
}
150159
}
151160

152-
if (identifierStr == "&&") {
153-
return T_AND;
154-
}
155-
if (identifierStr == "||") {
156-
return T_OR;
157-
}
158161
if (identifierStr == "-") {
159162
// 负数
160163
if (isdigit(seek())) {
164+
NEXTCHAR;
161165
int token = _getNextToken();
162166
if (token == T_INTEGER) {
163167
yylval.int_value = -yylval.int_value;

test/case/webc_test/qsort.sy

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
int qsort(int a[],int left,int right){
2+
if (right <= left){
3+
ret -1;
4+
}
5+
int pivot = a[right];
6+
int i = left;
7+
int j = right - 1;
8+
wh(true){
9+
wh(a[i] < pivot){
10+
i = i + 1;
11+
}
12+
wh(a[j] > pivot && j >= left){
13+
j = j - 1;
14+
}
15+
if (i < j){
16+
int tmp = a[i];
17+
a[i] = a[j];
18+
a[j] = tmp;
19+
i = i + 1;
20+
j = j - 1;
21+
}
22+
el {
23+
out;
24+
}
25+
}
26+
int tmp = a[i];
27+
a[i] = pivot;
28+
pivot = tmp;
29+
qsort(a,left,i-1);
30+
qsort(a,i+1,right);
31+
ret 0;
32+
}
33+
34+
int main(){
35+
int a[5]= {4,7,1,2,3};
36+
qsort(a,0,4);
37+
lp(int i=0;i<5;i=i+1){
38+
echo(a[i]);
39+
}
40+
}

0 commit comments

Comments
 (0)