Skip to content

Commit

Permalink
init rust
Browse files Browse the repository at this point in the history
remove brun mode
update docs
  • Loading branch information
limuy2022 committed Dec 24, 2023
1 parent bad65f1 commit 924c0b4
Show file tree
Hide file tree
Showing 42 changed files with 915 additions and 1,529 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/linux.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/macos.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/windows.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
build/
out/
bin/
bison/
cmake_third_party/
Testing/
CMakeFiles/
Expand All @@ -22,6 +23,9 @@ compile_commands.json
#clangd缓存
.cache/

#for rust
target/

*.aps
*.ctree
*.cbp
Expand All @@ -36,6 +40,10 @@ testlog.log
*.a
*.exp
*.pdb
token.cpp
parser.cpp
parser.hpp
location.hh

# 单元测试中的临时输出文件
*.out
31 changes: 20 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")

add_subdirectory("cmake_third_party/googletest")
include_directories("cmake_third_party/googletest/googletest/include")
include_directories("cmake_third_party/googletest/googletest/include", "include")

add_library(language_module)
target_sources(language_module
PUBLIC
FILE_SET CXX_MODULES FILES
language/language.cppm
PUBLIC
FILE_SET CXX_MODULES FILES
language/language.cppm
)

message("${LANGUAGE_SOURCES}")
Expand All @@ -42,9 +42,9 @@ message(${CPP_SOURCES})
add_library(foo)

target_sources(foo
PUBLIC
FILE_SET CXX_MODULES FILES
${CPPMSOURCES}
PUBLIC
FILE_SET CXX_MODULES FILES
${CPPMSOURCES}
)

add_executable(Trc ${CPP_SOURCES})
Expand All @@ -58,10 +58,10 @@ file(GLOB_RECURSE TEST_MODULE_SOURCES "tests/unittest/*.cppm")
add_library(testmodulefiles)

target_sources(testmodulefiles
PUBLIC
FILE_SET CXX_MODULES FILES
${CPPMSOURCES}
${TEST_MODULE_SOURCES}
PUBLIC
FILE_SET CXX_MODULES FILES
${CPPMSOURCES}
${TEST_MODULE_SOURCES}
)

add_executable(unittest
Expand All @@ -70,3 +70,12 @@ add_executable(unittest
)
target_compile_definitions(unittest PRIVATE "UNITTEST")
target_link_libraries(unittest testmodulefiles language gtest)
add_dependencies(Trc flex bison)
add_dependencies(unittest flex bison)

add_custom_target(flex
command flex -o ${PROJECT_SOURCE_DIR}/src/compiler/token.cpp ${PROJECT_SOURCE_DIR}/src/compiler/token.ll
)
add_custom_target(bison
command bison -o ${PROJECT_SOURCE_DIR}/src/compiler/parser.cpp ${PROJECT_SOURCE_DIR}/src/compiler/parser.yy
)
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Trc's syntax is easy,and have full toolchain.It is easy to learn modern c++ and

Using c++ 20 standard and use module feature

But here is a developing ```rust``` instance now!

in directory ```rust```

## Goal

#### as easy as Python
Expand Down
18 changes: 18 additions & 0 deletions doc/developer/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Docs that developer had used

Maybe these docs can help you develop this project more easily

|name|
|:---|
|[Flex Docs](http://westes.github.io/flex/manual/)|
|[Bison Docs](https://www.gnu.org/software/bison/manual/)|
|[Compiler Test](https://gnuu.org/2009/09/18/writing-your-own-toy-compiler/)|

|something maybe useful|
|:---|
|[Flexcpp](https://fbb-git.gitlab.io/flexcpp/manual/flexc++01.html#l3)|

|Chinese reference|
|:---|
|[Basic Usage of flex and bison](https://blog.csdn.net/weixin_44007632/article/details/108666375)|

42 changes: 37 additions & 5 deletions doc/use/use.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Trc使用说明

### 由于作者经常在更新项目时忘记更新文档,所以文档可能不会很完整,也许有不少的功能是只有从源码中才能发现的

### 1.编写基础和注意事项

1.双引号等同于单引号
Expand Down Expand Up @@ -35,7 +33,7 @@
例:import 'module1'

2.退出程序:
exit()
exit(exit_code)

### 4.输入输出

Expand All @@ -60,24 +58,59 @@
1.条件分支:
if 条件表达式 {
语句块
} else if 条件表达式 {

} else {

}

例如:
if a == 1 {
print(a)
} else {

}

2.条件循环:


while 条件表达式 {
语句块
} else {

}


3.function(函数)
定义:func xxx(a, b, n) {
定义

func xxx(a, b, n) {

}

调用:xxx()

4.异常处理语句


try {

} catch error {

} else {

} finally {

}


5.goto
例如:

label:
print(90)
goto label

### 6.逻辑运算符

1.== 相等
Expand All @@ -99,7 +132,6 @@
5.% 模运算
6.** 乘方
7.// 整除
注:当运算符两边数据类型不相同时,会以左边的数据类型为准进行类型强制转化
除法/是浮点型除法,需要整数除法请使用整除//

### 8.类型强制转换
Expand Down
Loading

0 comments on commit 924c0b4

Please sign in to comment.