国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

代做Micro Language Compiler

時間:2024-02-07  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



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.
如有需要,請加QQ:99515681 或WX:codehelp

掃一掃在手機打開當前頁
  • 上一篇:COM3524代做、代寫Java,Python編程設計
  • 下一篇:CISC3025代做、代寫Java,c++設計編程
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    流體仿真外包多少錢_專業CFD分析代做_友商科技CAE仿真
    流體仿真外包多少錢_專業CFD分析代做_友商科
    CAE仿真分析代做公司 CFD流體仿真服務 管路流場仿真外包
    CAE仿真分析代做公司 CFD流體仿真服務 管路
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真技術服務
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲勞振動
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲
    流體cfd仿真分析服務 7類仿真分析代做服務40個行業
    流體cfd仿真分析服務 7類仿真分析代做服務4
    超全面的拼多多電商運營技巧,多多開團助手,多多出評軟件徽y1698861
    超全面的拼多多電商運營技巧,多多開團助手
    CAE有限元仿真分析團隊,2026仿真代做咨詢服務平臺
    CAE有限元仿真分析團隊,2026仿真代做咨詢服
    釘釘簽到打卡位置修改神器,2026怎么修改定位在范圍內
    釘釘簽到打卡位置修改神器,2026怎么修改定
  • 短信驗證碼 寵物飼養 十大衛浴品牌排行 suno 豆包網頁版入口 wps 目錄網 排行網

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看
    久久综合中文色婷婷| 99三级在线| 国产精品视频免费一区| 欧美怡春院一区二区三区 | 国产精品免费观看高清| 国产成人中文字幕| 久久人人九九| 色婷婷成人综合| 国产精品手机视频| 久久99视频精品| 亚洲欧洲一区二区福利| 日韩av免费电影| 欧美在线视频一区二区三区| 欧美日韩在线播放一区二区| 精品视频一区在线| 99久久精品无码一区二区毛片| 国产极品在线视频| 国产成人涩涩涩视频在线观看| 国产精品久久久久aaaa九色| 久久国产精品网站| 亚洲欧洲日本国产| 日韩av电影免费在线| 欧美有码在线视频| 欧美精品欧美精品| 国产欧美久久久久久| 91免费视频国产| 久久99国产精品99久久| 国产精品久久久| 亚洲免费精品视频| 欧美激情 国产精品| 成人黄动漫网站免费| 国产成人一区二区三区小说| 国产精品涩涩涩视频网站| 中文字幕一区二区三区四区五区 | 国产精品日韩一区二区免费视频| 久热精品在线视频| 色香蕉在线观看| 精品日本一区二区| 99久热re在线精品996热视频| 色偷偷88888欧美精品久久久| 久久777国产线看观看精品| 日本一级淫片演员| 国产午夜福利在线播放 | www.99久久热国产日韩欧美.com| 蜜臀久久99精品久久久久久宅男| 亚洲国产欧美日韩| 国产中文字幕在线免费观看| 国产成人精品视| 欧美激情一级精品国产| 男人添女人下部高潮视频在观看| 91精品国产综合久久男男| 国产精品免费在线| 日韩av在线第一页| aaa级精品久久久国产片| 国产精品青青在线观看爽香蕉| 午夜久久久久久久久久久| 国产亚洲综合视频| 精品国产欧美一区二区五十路| 懂色av粉嫩av蜜臀av| 国产熟女高潮视频| 日韩有码在线电影| 亚洲a在线播放| 国产精品一区二区女厕厕| 国产精品美女午夜av| 秋霞在线观看一区二区三区| 久久婷婷五月综合色国产香蕉| 一区二区三区av在线| 国产美女精品视频| 免费91麻豆精品国产自产在线观看 | 日本高清不卡一区二区三| www日韩在线观看| 久久av资源网站| 欧美精品免费观看二区| 久久免费视频这里只有精品| 午夜精品视频网站| 91精品国产综合久久香蕉的用户体验 | 日韩欧美黄色大片| 国产精品一区二区免费在线观看| 久久九九亚洲综合| 国产精品久久久久久久久久新婚| 欧美一区二区视频在线| 国产精自产拍久久久久久蜜| 国产精品国产一区二区| 欧美日韩精品一区| 日韩中文字幕免费看| 日本精品久久久久影院| 久久人人爽人人| 三级网在线观看| 久久久免费在线观看| 亚洲国产婷婷香蕉久久久久久99| www日韩av| 久久久久久91| 国产精品香蕉国产| 欧美人与物videos| 国产日韩在线免费| 久久国产精品影片| 不卡视频一区二区三区| 中文字幕在线中文字幕日亚韩一区| 国产乱人伦真实精品视频| 中文字幕免费高| 9191国产视频| 秋霞成人午夜鲁丝一区二区三区| 日韩中文字幕精品视频| 黄瓜视频免费观看在线观看www| 国产精品露脸av在线| 国产原创精品| 精品国产福利| 99久re热视频这里只有精品6| 三年中文高清在线观看第6集| 国产成人+综合亚洲+天堂| 欧洲美女7788成人免费视频| 久久久久亚洲av无码专区喷水| 青青草一区二区| 国产精品久久久91| 丰满少妇久久久| 三级网在线观看| 国产精品视频专区| 国产精品自拍小视频| 午夜精品久久久久久久99黑人 | 国产精品少妇在线视频| 国产亚洲综合视频| 婷婷久久五月天| 久久精品国产免费观看| 国产青青在线视频| 日本亚洲欧美三级| 欧美精品一区在线播放| 国产精品 欧美在线| 欧美精品一区二区三区久久| 伊人久久99| 久久久999成人| 91精品免费| 麻豆91av| 午夜精品免费视频| 婷婷久久五月天| 蜜臀久久99精品久久久久久宅男 | 亚洲一二区在线| 国产不卡一区二区三区在线观看 | 国产二级片在线观看| 国产网站免费在线观看| 日本一级黄视频| 尤物av无码色av无码| 国产精品一级久久久| 日本视频一区二区不卡| 欧美大片va欧美在线播放| 91av网站在线播放| 国产在线精品一区| 欧美综合在线第二页| 亚洲国产欧洲综合997久久| 国产精品久久久久久久久久久久久久 | 免费在线国产精品| 中文精品一区二区三区| 久久久久久久国产精品视频| 欧美亚洲免费在线| 在线国产99| 九色自拍视频在线观看| 国产欧美一区二区视频| 日韩人妻精品一区二区三区| 久久综合伊人77777| 成人乱人伦精品视频在线观看| 欧美在线精品免播放器视频| 伊人色综合久久天天五月婷| 国产成人午夜视频网址| 久久五月天婷婷| 国产精品亚洲不卡a| 激情五月亚洲色图| 欧美一区二区色| 久久成人一区二区| 久久精品国产综合精品| chinese少妇国语对白| 狠狠色综合网站久久久久久久| 天天综合色天天综合色hd| 久久99精品久久久久久青青91| 国产成人涩涩涩视频在线观看| 欧美成ee人免费视频| 亚洲一区二区三区欧美| 久久久久久久久久久久久久国产 | 丰满爆乳一区二区三区| 亚洲wwwav| 国产精品久久久久久久电影| 国产成人精品久久二区二区| 国产伦精品一区二区三区四区视频| 青草青草久热精品视频在线网站| 精品国产日本| 久久久国产视频| 久久国产精品久久| 97精品视频在线| 国产中文一区二区| 免费观看美女裸体网站| 日韩精品―中文字幕| 亚洲精品日韩在线观看| 久久五月情影视| 国产精品视频公开费视频| 久久久久久久香蕉| 国产成人一区二区在线| 久久伊人资源站| 少妇免费毛片久久久久久久久| 最新欧美日韩亚洲| 久久精品国产精品| zzjj国产精品一区二区| 成人免费网站在线|