前言
年初花了2个月做这个,期间把代码给群里view但是大多报错太多,那时我还是不知道什么原因。4月左右总结了最后一个项目后,就想这下不会再有错了吧!(都是VS2017害的)
最近无聊,用VSCode下载了mingw运行了下代码,好多错…
VSCode运行CPP项目
安装Code Runner
C/C++
GBKtoUTF8几个插件,下载安装mingw,将
D:\Program Files\mingw64\bin
加入环境变量,然后打开一个新的文件夹,写个简单的CPP或者C的文件,运行下F5或者右上角的三角
——有时用快捷键有冲突,需要修改快捷键——设置->键盘快捷方式->…
好像不用自己写settings.json和tasks.json和launch.json,
运行了单个CPP或C后还不能运行项目,需要修改Code Runner配置:
把原本
$filename
改成
*.cpp
"cpp": "cd $dir && g++ *.cpp -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
这样就行了,但有时另一个本地的也要改成这样:
Suatin
链接:https://pan.baidu.com/s/1r7ND6XZac_QQS6UtdrD_gg
提取码:is91
复制这段内容后打开百度网盘手机App,操作更方便哦
用Suatin解释器写.suatin程序
CMD进入main.exe目录,在旁边放xx.suatin文件
//main.suatin
i=1;
sum=2;
if(sum >= i + 1)
sum=0;
end
do
i=i+1;
sum=sum+i;
if(sum==7)
break;
end
until(i>10)
C:\Users\Suatin>e:
E:\>cd E:\try_suatin
E:\try_suatin>dir
Volume in drive E has no label.
Volume Serial Number is A63C-7570
Directory of E:\try_suatin
2020/10/02 12:53 <DIR> .
2020/10/02 12:53 <DIR> ..
2020/10/02 12:53 <DIR> .vscode
2020/10/02 03:23 5,583 Cmd.cpp
2020/10/02 03:24 5,122 Cmd.h
2020/10/02 03:24 13,554 Expr.cpp
2020/10/02 03:24 10,019 Expr.h
2020/10/02 03:24 1,066 main.cpp
2020/10/02 03:24 2,305,453 main.exe
2020/10/02 03:28 112 main.suatin
2020/10/02 03:23 62,302 Parser.cpp
2020/10/02 03:23 5,383 Parser.h
2020/10/02 03:23 36,864 Resolver.cpp
2020/10/02 03:23 4,337 Resolver.h
2020/05/03 20:34 5,394 teach.txt
2020/10/02 03:23 13,746 Utils.cpp
2020/10/02 03:23 12,346 Utils.h
14 File(s) 2,481,281 bytes
3 Dir(s) 19,212,574,720 bytes free
E:\try_suatin>main main.exe
文件不是suatin类型文件
E:\try_suatin>main main.suatin
local infix expression>
name pos type keyword
i 0 10 0
= 1 23 0
1 2 7 0
; 3 32 0
sum 4 10 0
= 5 23 0
2 6 7 0
; 7 32 0
if 8 10 1
( 9 27 0
sum 10 10 0
>= 11 17 0
i 12 10 0
+ 13 15 0
1 14 7 0
) 15 28 0
sum 16 10 0
= 17 23 0
0 18 7 0
; 19 32 0
end 20 10 16
do 21 10 7
i 22 10 0
= 23 23 0
i 24 10 0
+ 25 15 0
1 26 7 0
; 27 32 0
sum 28 10 0
= 29 23 0
sum 30 10 0
+ 31 15 0
i 32 10 0
; 33 32 0
if 34 10 1
( 35 27 0
sum 36 10 0
== 37 22 0
7 38 7 0
) 39 28 0
break 40 10 5
; 41 32 0
end 42 10 16
until 43 10 8
( 44 27 0
i 45 10 0
> 46 19 0
10 47 7 0
) 48 28 0
suatin abstract syntax tree>
[0]
=
├── i
└── 1
[1]
=
├── sum
└── 2
[2]
>=
├── sum
└── +
├── i
└── 1
[3]
=
├── sum
└── 0
[4]
=
├── i
└── +
├── i
└── 1
[5]
=
├── sum
└── +
├── sum
└── i
[6]
==
├── sum
└── 7
[7]
>
├── i
└── 10
suatin semantic tree>
block
├── [0]
├── [1]
├── if
│ ├── cond
│ │ └── [2]
│ └── block
│ └── [3]
└── do-until
├── block
│ ├── [4]
│ ├── [5]
│ └── if
│ ├── cond
│ │ └── [6]
│ └── block
│ └── break
└── cond
└── [7]
suatin environment>
------------------------------------------------------------------------------
name type value
NIL nil false
FALSE bool false
TRUE bool true
i number 11
sum number 65
------------------------------------------------------------------------------
program time consumed 263 ms
E:\try_suatin>
teach.txt是教程
压缩包里有suatin语言编写的教程