联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2019-12-23 08:52

Assessed Exercise 2, Task 1

Implement the part of the language in black. No need to implement code generation for the red

parts. No test for this task will feature programs containing language constructs in red. Your code

generator can throw CodegenException for the ASTs that correspond to language constructs in

red, or you can return RISC-V code, it does not matter.

PROG → DEC | DEC; PROG

DEC → def ID (VARDEC) = E

VARDEC → ε | VARDECNE

VARDECNE → ID | VARDECNE, ID

ID → ... (identifiers)

INT → ... (Integers)

E → INT

| ID

| if E COMP E then E else E endif

| (E BINOP E)

| (E)

| ID(ARGS)

| skip

| (E; E)

| while E COMP E do E endwhile

| repeat E until E COMP E endrepeat

| ID := E

| break

| continue

ARGS → ε | ARGSNE

ARGSNE → E | ARGSNE, E

COMP → == | < | > | <= | >=

BINOP → + | - | * | /

Recall that the relevant definitions are here, here and here (and in the Zip file / Github given on the

parent page). If you don't want to implement a feature, simply throw CodegenException when

the code generator encounters this feature.

Note that the translation of procedure invocation (given by the production E → ID(ARGS) in the

grammar above) is part of Task 1. Since every program will have at least one procedure invocation,

I strongly suggest that you focus on getting this right.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp