anonymousaaardvark / qi Goto Github PK
View Code? Open in Web Editor NEWLightweight and fast programming language designed to be written in Chinese.
Home Page: https://anonymousaaardvark.github.io/qi/
License: MIT License
Lightweight and fast programming language designed to be written in Chinese.
Home Page: https://anonymousaaardvark.github.io/qi/
License: MIT License
使用以下补丁可修复:
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,5 +5,8 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
+if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ set(CMAKE_EXE_LINKER_FLAGS "-lm")
+endif()
add_executable(qi main.c common.h chunk.h chunk.c memory.h memory.c debug.h debug.c value.h value.c vm.h vm.c compiler.h compiler.c scanner.h scanner.c object.h object.c table.h table.c common.h chunk.h chunk.c compiler.c compiler.h core_module.c core_module.h)
官网教程例子如下:
1 功能 斐波(数字)「
2 如果(数字 小 2)返回 数字
3 返回 斐波(数字 - 2) + 斐波(数字 - 1)
4」
5
6 系统。打印行(斐波(20))
报错如下:
> qi hello.qi
操作数必须是数字。
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 3】在 斐波()
【行 6】在 脚本
请问这是什么原因?是我哪里不对吗?
但是没必要
syntax.md文件里,保留关键字里,应该是 ”大等“,而不是”打等“。
Hello! This is a really cool language concept & fun to use. I noticed when writing some code in this that the 系统。扫描()
function seems to have some strange behavior with long lines.
If you read a line more than 98 characters wide, 系统。扫描()
will return only the first 98 bytes. If you then call 系统。扫描()
again, it will return the next 98 characters, but it will skip one character.
So:
[---first 98 bytes---][1 byte][---next 98 bytes--]\n
^ first 系统。扫描() ^ second 系统。扫描()
It looks like this is just because the 系统。扫描()
function has a static array on the stack.
Let me know if you'd like me to write a quick patch for that to allocate the array dynamically! Besides that the language seems to be really solid. I wrote a binary heap and Dijkstra's algorithm, and the performance is good.
(I also noticed that the language will hang indefinitely if 扫描
gets an EOF.)
# 系统版本
Linux kensan 5.13.0-30-generic #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# gcc 版本
gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
# cmake 版本
cmake version 3.22.2
# make 版本
GNU Make 4.2.1
-- The C compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /gitrepositry/qi/src
/usr/bin/ld: CMakeFiles/qi.dir/vm.c.o: in function `run':
vm.c:(.text+0x43e0): undefined reference to `fmod'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `sqrtNative':
core_module.c:(.text+0x5cb): undefined reference to `sqrt'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `powNative':
core_module.c:(.text+0x6d5): undefined reference to `pow'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `roundNative':
core_module.c:(.text+0xa3c): undefined reference to `pow'
/usr/bin/ld: core_module.c:(.text+0xa5e): undefined reference to `round'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `logNative':
core_module.c:(.text+0xcd9): undefined reference to `log'
/usr/bin/ld: core_module.c:(.text+0xcec): undefined reference to `log'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `sinNative':
core_module.c:(.text+0xd8c): undefined reference to `sin'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `cosNative':
core_module.c:(.text+0xe1f): undefined reference to `cos'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `tanNative':
core_module.c:(.text+0xeb2): undefined reference to `tan'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `asinNative':
core_module.c:(.text+0xf45): undefined reference to `asin'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `acosNative':
core_module.c:(.text+0xfd8): undefined reference to `acos'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `atanNative':
core_module.c:(.text+0x106b): undefined reference to `atan'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `ceilNative':
core_module.c:(.text+0x10fe): undefined reference to `ceil'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `floorNative':
core_module.c:(.text+0x1191): undefined reference to `floor'
/usr/bin/ld: CMakeFiles/qi.dir/core_module.c.o: in function `randNative':
core_module.c:(.text+0x12dc): undefined reference to `round'
/usr/bin/ld: core_module.c:(.text+0x12f9): undefined reference to `round'
/usr/bin/ld: core_module.c:(.text+0x1318): undefined reference to `round'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/qi.dir/build.make:257:qi] 错误 1
make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/qi.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2
具体编译信息make_info.txt
如 系统。打印行("一")
,看起来对应着英文编程语言中的句点。
个人感觉,英文编程语言设计中选择句点是取其“从属”之意(比如章节号 1.2.3、A.1,版本号 3.4.0 等)而非句尾之意,而中文句点传统上只有句尾标志一种含义。
不知考虑过用其他符号如间隔号 · 吗?它可用于书名与篇(章、卷)名之间的分界。例如:《论语·里仁》《孟子·梁惠王》《三国志·蜀志·诸葛亮传》
代码是直接复制官网例子的
类 树 「
功能 打印()「
系统。打印行("我是一个树!")
」
」
变量 式 = 树()
系统。打印行(式。打印())
命令行运行直接出现错误
> qi hello.qi
【行 2】错误在「功能」:期待方法名。
【行 7】错误在「变量」:期待方法名。
【行 9】错误在末尾:块后期待「 」」。
「打断」陈述和下面的“继续”陈述里有这样两段代码
// 打断代码
变量 日志 = 【"好","好","好","错误","好","好"】
对于(变量 i = 0;i 小 日志。长度();i++)「
如果(日志【i】等 "错误")「
系统。打印行("错误在:" + 数到串(i)+ "行")
打断
」
」
// 继续代码
变量 列表 = 【482,9654,861,6720,5738,2045,18397】
对于(变量 i = 0;i 小 列表。长度();i++)「
如果(列表【i】% 2 等 0)继续
系统。打印(数到串(列表【i】)+ " ")
」
系统。打印行("")
这两段的无法运行,打印语句都使用了方法“数到串()”,但是该方法并没有引入或定义,直接运行代码就报错了。得到错误提示如下
未定义的变量「数到串」。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.