COMP 3002 Winter 2020 Assignment #3
Building a Compiler
COMP 3002代写 Build a class called StudentCompiler using SampleTranslator from the previous assignment as a model. After you find
Basic goals: To implement a compiler with for loops, if statements, and simple expressions.
Where to start… COMP 3002代写
Build a class called StudentCompiler using SampleTranslator from the previous assignment as a model. Note: that we explicitly designed these tables so that NO MAP IS NEEDED. After you find where the scanner and parser tables are in SampleTranslator, place the new tables in the corresponding place in your StudentCompiler. COMP 3002 Winter 2020 Assignment #3
Note that instead of calling your walk routine “compileExpressionFor: tree” which is what it was called in the SampleTranslator, yours should be called “walkTree: tree”. Output your code in an ordered collection called code.
After that, build yourself a few example methods containing code you want to compile such as
asic 目标:实现带有 for 循环、if 语句和简单表达式的编译器。
从哪儿开始…
使用之前作业中的 SampleTranslator 作为模型构建一个名为 StudentCompiler 的类。 注意:我们明确设计了这些表,因此不需要地图。 在您找到扫描器和解析器表在 SampleTranslator 中的位置后,将新表放置在 StudentCompiler 中的相应位置。
请注意,不是调用您的 walk 例程“compileExpressionFor: tree”,这就是它在 SampleTranslator 中的名称,您的应称为“walkTree: tree”。 在名为 code 的有序集合中输出您的代码。
之后,为自己构建一些包含要编译的代码的示例方法,例如
example1
“StudentCompiler example1”
StudentCompiler compile: 'if (a > b) {a = b; c = d} else {e = f;}'
and you are ready to start. Note: We don’t deal with variable declarations in this assignment. Nor do we store variable values. So don’t include variables from SampleTranslator that you don’t need.
Hint: It is possible to copy code that is in Powerpoint provide you delete funny characters that you don’t want. Some example funny characters are slanted single or double quotes and sometimes the character “-“ turns out to be something other than a minus sign.
If any of my code has a bug, fix it and let me know.
例子1 COMP 3002代写
“StudentCompiler 示例 1”
StudentCompiler 编译:'if (a > b) {a = b; c = d} else {e = f;}'
您已准备好开始。 注意:我们不处理这个赋值中的变量声明。 我们也不存储变量值。 所以不要包含来自 SampleTranslator 的你不需要的变量。
提示:如果您删除不需要的有趣字符,则可以复制 Powerpoint 中的代码。 一些示例有趣的字符是倾斜的单引号或双引号,有时字符“-”不是减号。如果我的任何代码有错误,请修复它并告诉我。
商科代写 cs代写 法律学代写 经济学代考_经济学作业代写 艺术代写 心理学代写 哲学代写 伦理学代写 体育学代写 化学代写 教育学代写 医学代写 历史代写 地理学代写
发表回复
要发表评论,您必须先登录。