课程主页:

https://www.edx.org/course/compilers

课程视频:

https://www.bilibili.com/video/BV1NE411376V?p=20&t=6

参考资料:

http://pashabd.com/how-to-install-classroom-object-oriented-language-cool-programming-in-your-windows-computer/

https://courses.edx.org/courses/course-v1:StanfordOnline+SOE.YCSCS1+2T2020/7b74698308574f3c89d2ed498f26a019/

https://www.jianshu.com/p/12fbfa8c7489

这次介绍如何在ubuntu下配置Stanford Compiler的实验环境。

实验环境配置

将课程资料下载到ubuntu内:

https://courses.edx.org/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@asset+block@student-dist.tar.gz

然后保存在一个英文目录下,其中bin文件夹内包含coolc以及spim的解释器,比如我的位置是

/usr/class/bin

然后修改环境变量:

sudo gedit ~/.bashrc

在最后一行添加如下命令:

export PATH=/usr/class/bin:$PATH

试运行:

qz@qz-virtual-machine:/usr/class/bin$ coolc
Class Main is not defined.
Compilation halted due to static semantic errors.
qz@qz-virtual-machine:/usr/class/bin$ spim
/usr/class/bin/spim: 第 55 行: [: !=:需要一元表达式
SPIM Version 6.5 of January 4, 2003
Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu).
All Rights Reserved.
See the file README for a full copyright notice.
Loaded: ../lib/trap.handler
(spim) 

运行成功。