99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

合肥生活安徽新聞合肥交通合肥房產(chǎn)生活服務(wù)合肥教育合肥招聘合肥旅游文化藝術(shù)合肥美食合肥地圖合肥社保合肥醫(yī)院企業(yè)服務(wù)合肥法律

代做Micro Language Compiler

時(shí)間:2024-02-07  來源:合肥網(wǎng)hfw.cc  作者:hfw.cc 我要糾錯(cuò)



Assignment 1: Micro Language Compiler
1 Introduction
In this assignment, you are required to design and implement a compiler frontend for Micro
language which transforms the Micro Program into corresponding LLVM Intermediate Representation (IR) and finally translated to RISC-V assembly code and executable with the help of
LLVM optimizer and its RISC-V backend. After that, we can execute the compiled program on our
RISC-V docker container to verify the correctness of your compiler.
Since it is a senior major elective course, we don’t want to set any limitation for you. You are strongly
recommended to use Lex/Flex and Yacc/Bison taught in tutorial 3 to design your compiler frontend,
but it is not forcible. You can choose Any Programming Language you like for this assignment,
but the RISC-V container we use only has C/C++ toolchain installed and you need to provide me a
Dockerfile to run your compiler and execute the RISC-V program, which may need some extra effort.
Some languages also provide tools like Lex and Yacc, and you are free to use them. It is also OK if
you want to design the scanner and parser by hand instead of using tools.
2 Micro Language
Before we move on to the compiler design, it is necessary to have an introduction to Micro Language,
that serves as the input of our compiler. Actually, it is a very simple language, with limited number
of tokens and production rules of context-free grammar (CFG):
• Only integers(i**); No float numbers
• No Declarations
• Variable consists of a-z, A-Z, 0-9, at most ** characters long, must start with character and are
initialized as 0
• Comments begin with ”−−” and end with end-of-line(EOL)
• Three kind of statements:
– assignments, e.g. a:=b+c
– read(list of IDs), e.g. read(a, b)
– write(list of Expressions), e.g. write (a, b, a+b)
• BEGIN, END, READ, WRITE are reserved words
• Tokens may not extend to the following line
1
2.1 Tokens & Regular Expression
Micro Language has 14 Tokens, and the regular expression for each token is listed below. Since BEGIN
is a reserved word in C/C++, we need to use the alternative BEGIN as the token class.
1. BEGIN : begin
2. END: end
3. READ: read
4. WRITE: write
5. LPAREN: (
6. RPAREN: )
7. SEMICOLON: ;
8. COMMA: ,
9. ASSIGNOP: :=
10. PLUSOP: +
11. MINUSOP: −
12. ID: [a−zA−Z][a−zA−Z0−9 ]{0,31}
13. INTLITERAL: −?[0−9]+
14. SCANEOF: <<EOF>>
2.2 Context Free Grammar
Here is the extended context-free grammar (CFG) of Micro Language:
1. <start> → <program> SCANEOF
2. <program> → BEGIN <statement list> END
3. <statement list> → <statement> {<statement>}
4. <statement> → ID ASSIGNOP <expression>;
5. <statement> → READ LPAREN <id list> RPAREN;
6. <statement> → WRITE LPAREN<expr list> RPAREN;
7. <id list > → ID {COMMA ID}
8. <expr list > → <expression> {COMMA <expression>}
9. <expression> → <primary> {<add op> <primary>}
10. <primary> → LPAREN <expression> RPAREN
11. <primary> → ID
12. <primary> → INTLITERAL
13. <add op> → PLUSOP
14. <add op> → MINUSOP
Note: {} means the content inside can appear 0, 1 or multiple times.
2.3 How to Run Micro Compiler
Here is a very simple Micro program that we are going to use as the sample program throughout this
instruction. SCANEOF is the end of line and we do not need to explicitly write it in the program.
−− Expected Output: 30
begin
A := 10;
B := A + 20;
write (B);
end
We can use our compiler to compile, optimize and execute this program to get expected output 30.
Note: The exact command to run your compiler is up to you. Just specify out in your report how
to compile and execute your compiler to get the expected output.
118010200@c2d52c9b1339:˜/A1$ ./compiler ./testcases/test0.m
118010200@c2d52c9b1339:˜/A1$ llc −march=riscv64 ./program.ll −o ./program.s
118010200@c2d52c9b1339:˜/A1$ riscv64−unknown−linux−gnu−gcc ./program.s −o ./program
118010200@c2d52c9b1339:˜/A1$ qemu−riscv64 −L /opt/riscv/sysroot ./program
30
2
3 Compiler Design
Figure 1 shows the overall structure of a compiler. In this assignment, your task is to implement the
frontend only, which contains scanner, parser and intermediate code generator and form a whole →
compiler with LLVM for Micro language.
Figure 1: Compiler Structure
3.1 Scanner
Scanner takes input character stream and extracts out a series of tokens, and your scanner should
be able to print out both token class and lexeme for each token. Figure ?? shows an example of the
sample Micro program.
118010200@c2d52c9b1339:˜/A1$ ./compiler ./testcases/test0.m −−scan−only
BEGIN begin
ID A
ASSIGNOP :=
INTLITERAL 10
SEMICOLON ;
ID B
ASSIGNOP :=
ID A
PLUOP +
INTLITERAL 20
SEMICOLON ;
WRITE write
LPAREN (
ID B
RPAREN )
SEMICOLON ;
END end
SCANEOF
3
3.2 Parser
Parser receives the tokens extracted from scanner, and generates a parse tree (or concrete syntax tree),
and futhermore, the abstract syntax tree (AST) based on the CFG. Your compiler should be able to
print out both the parse tree and the abstract syntax tree, and visualize them with graphviz.
3.2.1 Parse Tree (Concrete Syntax Tree)
Figure 2 shows an example of the concrete syntax tree generated from the sample program:
Figure 2: Concrete Syntax Tree of Sample Program
3.2.2 Abstract Syntax Tree
Figure 3 shows an example of the abstract syntax tree generated from the sample program:
Figure 3: Abstract Syntax Tree of Sample Program
4
3.3 Intermediate Code Generator
For all the assignments in this course, the intermediate representation (IR) of the compiler should be
the LLVM IR. There are mainly two reasons why LLVM IR is chosen. One is that LLVM IR can take
advantage of the powerful LLVM optimizer and make up for the missing backend part of compiler in
this course. The other is that LLVM IR can be easier translated into assembly code for any target
machine, no matter MIPS, x86 64, ARM, or RISC-V. This functionality can make our compiler more
compatible to machines with different architecture. The following shows the LLVM IR generated for
the sample Micro program:
; Declare printf
declare i** @printf (i8 ∗, ...)
; Declare scanf
declare i** @scanf(i8 ∗, ...)
define i** @main() {
% ptr0 = alloca i**
store i** 10, i**∗ % ptr0
%A = load i**, i**∗ % ptr0
% 1 = add i** %A, 20
store i** % 1, i**∗ % ptr0
%B = load i**, i**∗ % ptr0
% scanf format0 = alloca [4 x i8 ]
store [4 x i8 ] c”%d\0A\00”, [4 x i8]∗ % scanf format0
% scanf str0 = getelementptr [4 x i8 ], [4 x i8]∗ % scanf format0, i** 0, i** 0
call i** (i8 ∗, ...) @printf (i8∗ % scanf str0 , i** %B)
ret i** 0
}
3.4 Bonus (Extra Credits 10%)
If you are interested and want to make your compiler better, you may try the following options:
• Add robust syntax error report
• Add a symbol table to make your compiler more complete
• Generate LLVM IR with LLVM C/C++ API instead of simply generating the string
• Optimize the LLVM IR generation plan for more efficient IR
• Any other you can think about...
4 Submission and Grading
4.1 Grading Scheme
• Scanner: 20%
• Parser: 40% (20% for parse tree generator and 20% for AST generation)
• Intermediate Code Generator: 30%
We have prepared 10 test cases, and the points for each section will be graded according to the
number of testcases you passed.
• Technical Report: 10%
If your report properly covers the three required aspects and the format is clean, you will get 10
points.
5
• Bonus: 10%
Refer to section 3.4 for more details. The grading of this part will be very flexible and highly
depend on the TA’s own judgement. Please specify clearly what you have done for the bonus
part so that he do not miss anything.
4.2 Submission with Source Code
If you want to submit source C/C++ program that is executable in our RISC-V docker container,
your submission should look like:
csc4180−a1−118010200.zip
|−
|−−− csc4180−a1−118010200−report.pdf
|−
|−−− testcases
|−
|−−− src
|−
|−−−Makefile
|−−−ir generator.cpp
|−−−ir generator.hpp
|−−−node.cpp
|−−−node.hpp
|−−−scanner.l
|−−−parser.y
|−−−Other possible files
4.3 Submission with Docker
If you want to submit your program in a docker, your submission should look like:
csc4180−a1−118010200.zip
|−
|−−− csc4180−a1−118010200.Dockerfile
|−
|−−− csc4180−a1−118010200−report.pdf
|−
|−−− src
|−
|−−−Makefile
|−
|−−−run compiler.sh
|−
|−−−Your Code Files
4.4 Technical Report
Please answer the following questions in your report:
• How to execute your compiler to get expected output?
• How do you design the Scanner?
• How do you design the Parser?
• How do you design the Intermediate Code Generator?
• Some other things you have done in this assignment?
The report doesn’t need to be very long, but the format should be clean. As long as the three questions
are clearly answered and the format is OK, your report will get full mark.
如有需要,請(qǐng)加QQ:99515681 或WX:codehelp

掃一掃在手機(jī)打開當(dāng)前頁
  • 上一篇:COM3524代做、代寫Java,Python編程設(shè)計(jì)
  • 下一篇:CISC3025代做、代寫Java,c++設(shè)計(jì)編程
  • 無相關(guān)信息
    合肥生活資訊

    合肥圖文信息
    急尋熱仿真分析?代做熱仿真服務(wù)+熱設(shè)計(jì)優(yōu)化
    急尋熱仿真分析?代做熱仿真服務(wù)+熱設(shè)計(jì)優(yōu)化
    出評(píng) 開團(tuán)工具
    出評(píng) 開團(tuán)工具
    挖掘機(jī)濾芯提升發(fā)動(dòng)機(jī)性能
    挖掘機(jī)濾芯提升發(fā)動(dòng)機(jī)性能
    海信羅馬假日洗衣機(jī)亮相AWE  復(fù)古美學(xué)與現(xiàn)代科技完美結(jié)合
    海信羅馬假日洗衣機(jī)亮相AWE 復(fù)古美學(xué)與現(xiàn)代
    合肥機(jī)場巴士4號(hào)線
    合肥機(jī)場巴士4號(hào)線
    合肥機(jī)場巴士3號(hào)線
    合肥機(jī)場巴士3號(hào)線
    合肥機(jī)場巴士2號(hào)線
    合肥機(jī)場巴士2號(hào)線
    合肥機(jī)場巴士1號(hào)線
    合肥機(jī)場巴士1號(hào)線
  • 短信驗(yàn)證碼 豆包 幣安下載 AI生圖 目錄網(wǎng)

    關(guān)于我們 | 打賞支持 | 廣告服務(wù) | 聯(lián)系我們 | 網(wǎng)站地圖 | 免責(zé)聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網(wǎng) 版權(quán)所有
    ICP備06013414號(hào)-3 公安備 42010502001045

    99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

          9000px;">

                怡红院av一区二区三区| 天堂成人国产精品一区| 亚洲综合色区另类av| 国产成人av影院| 天天综合网天天综合色| 欧美一卡在线观看| 国内精品伊人久久久久影院对白| 精品国产精品一区二区夜夜嗨| 国产精品一区二区在线播放| 中文字幕精品在线不卡| 91丨国产丨九色丨pron| 亚洲国产成人精品视频| 日韩欧美中文字幕精品| 成人午夜视频在线观看| 亚洲成av人影院| 日韩欧美黄色影院| 成人av网在线| 日韩和欧美一区二区| 久久久久久影视| 一区二区三区.www| 精品人在线二区三区| eeuss鲁片一区二区三区在线看 | 久久女同精品一区二区| av一本久道久久综合久久鬼色| 尤物视频一区二区| 久久影院视频免费| 欧美三级中文字幕在线观看| 国产白丝精品91爽爽久久| 午夜精品久久久久久久蜜桃app| 亚洲6080在线| 国产精品美女视频| 精品久久久三级丝袜| 在线看国产日韩| 国产欧美视频在线观看| 日韩一二在线观看| 欧洲国内综合视频| 大白屁股一区二区视频| 精品一区二区三区日韩| 亚洲一区二区三区四区的| 国产亚洲欧美激情| 精品少妇一区二区三区视频免付费| 色婷婷综合久久久久中文一区二区 | 在线观看视频91| 国产91高潮流白浆在线麻豆| 美日韩一区二区| 日本中文一区二区三区| 亚洲激情图片一区| 国产精品传媒入口麻豆| 精品成人a区在线观看| 欧美一级在线视频| 欧美一区二区三区日韩视频| 欧美午夜精品电影| 一本色道久久综合亚洲91| 成人av在线播放网址| 丁香婷婷综合色啪| 成人夜色视频网站在线观看| 欧美色国产精品| 欧美三电影在线| 欧美一区二区免费| 日韩欧美国产一区二区三区| 777久久久精品| 精品国产一区二区三区av性色 | 国产色91在线| 久久一区二区三区四区| 亚洲国产精品t66y| 国产精品成人午夜| 亚洲黄色av一区| 亚洲国产精品久久久久婷婷884| 婷婷夜色潮精品综合在线| 免费日韩伦理电影| 国产很黄免费观看久久| 99re热这里只有精品免费视频| proumb性欧美在线观看| 欧美曰成人黄网| 日韩你懂的电影在线观看| 国产精品天干天干在线综合| 亚洲夂夂婷婷色拍ww47| 久久精品国产99| 99精品国产视频| 日韩一区二区视频| 亚洲欧美一区二区三区极速播放| 午夜激情综合网| 懂色av一区二区三区免费观看| 欧美日韩久久不卡| 亚洲欧洲www| 久久精品国产久精国产爱| 不卡av在线免费观看| 欧美一区二区三区视频免费| 亚洲人成伊人成综合网小说| 国产综合成人久久大片91| 欧美日韩一区成人| 成人欧美一区二区三区| 国模大尺度一区二区三区| 成人精品国产免费网站| 欧美剧在线免费观看网站| 亚洲日本va在线观看| 青青国产91久久久久久| 色综合天天天天做夜夜夜夜做| 欧美一区二区三区免费在线看 | 亚洲视频1区2区| 欧美精品一区二区久久久| 亚洲黄色尤物视频| 中文字幕高清不卡| 国产精品久久久久影院老司| 亚洲欧洲制服丝袜| 成人一区二区三区在线观看| 91在线观看美女| 色欧美片视频在线观看| 欧美一区二区三区公司| 欧美精品一区二区三区在线播放 | 视频精品一区二区| 青青草成人在线观看| 国内成人自拍视频| 99久久久久久| 国产精品九色蝌蚪自拍| 亚洲国产一区在线观看| 91成人国产精品| 亚洲精品在线免费观看视频| 成人性视频网站| 色八戒一区二区三区| 一区二区中文字幕在线| 午夜a成v人精品| 欧美一区日韩一区| 国产精品人妖ts系列视频| 亚洲第一搞黄网站| 国产白丝精品91爽爽久久| 国产一区二区日韩精品| 99亚偷拍自图区亚洲| 国模套图日韩精品一区二区| 在线日韩国产精品| 久久精品夜色噜噜亚洲aⅴ| 国产精品入口麻豆九色| 日本三级亚洲精品| 久久精品一级爱片| 人妖欧美一区二区| 色一情一乱一乱一91av| 久久美女艺术照精彩视频福利播放| 国产一区二区三区免费播放| 欧美亚洲动漫制服丝袜| 中文字幕一区二区日韩精品绯色| 麻豆一区二区三区| 欧美日韩高清影院| 亚洲精品一二三| 日韩一级高清毛片| 亚洲制服丝袜av| 91在线高清观看| 蜜臀av性久久久久蜜臀av麻豆 | 97精品久久久午夜一区二区三区| 欧美电影影音先锋| 欧美亚洲禁片免费| 精油按摩中文字幕久久| 欧美在线视频全部完| 亚洲欧美日韩在线不卡| 懂色av中文一区二区三区| 欧美大片在线观看一区二区| 成人成人成人在线视频| 久久人人97超碰com| 精品1区2区在线观看| 无码av免费一区二区三区试看 | 日本欧美一区二区| 欧美激情在线看| 国产精品亚洲午夜一区二区三区 | 日韩无一区二区| 午夜精品成人在线| 国产精品每日更新| 成人黄色软件下载| 日本不卡免费在线视频| 久久国产生活片100| 久久久精品日韩欧美| 成人夜色视频网站在线观看| 蜜臀av亚洲一区中文字幕| 亚洲精品精品亚洲| 欧美美女一区二区三区| 天涯成人国产亚洲精品一区av| 欧美精品在欧美一区二区少妇| av成人老司机| 亚洲麻豆国产自偷在线| 91久久免费观看| 爽好久久久欧美精品| 国产高清成人在线| 老司机免费视频一区二区| 久久色.com| 99久久精品情趣| 亚洲一区二区三区不卡国产欧美| |精品福利一区二区三区| 欧美专区亚洲专区| 久久99日本精品| 九色综合国产一区二区三区| 中文字幕欧美日本乱码一线二线| 久久精品国产久精国产爱| 免费一区二区视频| 国产欧美视频一区二区三区| 成人aa视频在线观看| 午夜亚洲国产au精品一区二区| 亚洲一区二区在线免费看| 久久久国产综合精品女国产盗摄| 成人手机电影网| 久久激情综合网| 国产精品亚洲专一区二区三区| 亚洲第一主播视频|