加勒比久久综合,国产精品伦一区二区,66精品视频在线观看,一区二区电影

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

代做Micro Language Compiler

時間:2024-02-07  來源:合肥網(wǎng)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++設計編程
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    2025年10月份更新拼多多改銷助手小象助手多多出評軟件
    2025年10月份更新拼多多改銷助手小象助手多
    有限元分析 CAE仿真分析服務-企業(yè)/產(chǎn)品研發(fā)/客戶要求/設計優(yōu)化
    有限元分析 CAE仿真分析服務-企業(yè)/產(chǎn)品研發(fā)
    急尋熱仿真分析?代做熱仿真服務+熱設計優(yōu)化
    急尋熱仿真分析?代做熱仿真服務+熱設計優(yōu)化
    出評 開團工具
    出評 開團工具
    挖掘機濾芯提升發(fā)動機性能
    挖掘機濾芯提升發(fā)動機性能
    海信羅馬假日洗衣機亮相AWE  復古美學與現(xiàn)代科技完美結(jié)合
    海信羅馬假日洗衣機亮相AWE 復古美學與現(xiàn)代
    合肥機場巴士4號線
    合肥機場巴士4號線
    合肥機場巴士3號線
    合肥機場巴士3號線
  • 短信驗證碼 目錄網(wǎng) 排行網(wǎng)

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

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

    欧美特黄aaaaaaaa大片| 91精品推荐| 国产成人a视频高清在线观看| 欧洲杯什么时候开赛| 亚洲涩涩av| 国产精品尤物| 中文字幕成在线观看| 亚洲精品一区二区妖精| 都市激情久久| 国产一区毛片| 日本在线观看不卡视频| 不卡av播放| 久久高清国产| 亚洲国产影院| 欧美三级午夜理伦三级中文幕 | 美女毛片一区二区三区四区最新中文字幕亚洲| www.九色在线| 国产视频一区三区| 香蕉人人精品| 欧美交a欧美精品喷水| 国产欧美日韩免费观看| 日本美女一区二区三区视频| 国产综合色区在线观看| 蜜桃91丨九色丨蝌蚪91桃色| 黄色亚洲免费| 亚洲五月婷婷| 久久中文字幕二区| 欧美色综合网| 中文一区二区三区四区| 欧美激情在线免费| 亚洲一区二区| 久久人人爽人人爽人人片av不| 成人国产精品| 91av一区| 日本h片久久| 桃色一区二区| 亚洲精品一级二级| 在线观看精品| 日本精品在线中文字幕| 日韩影院二区| 日韩电影二区| 日韩精品第一区| 欧美91看片特黄aaaa| 黑人精品一区| 日韩欧美网站| 69堂精品视频在线播放| 免费成人在线电影| 另类中文字幕国产精品| 小黄鸭精品aⅴ导航网站入口| 日韩精品2区| 91福利精品在线观看| 精品123区| 久久精品 人人爱| 亚欧美中日韩视频| 青青草91视频| 国产精品视频一区视频二区| 欧美经典影片视频网站| 国产在线日韩精品| 日韩高清二区| 成人精品天堂一区二区三区| 久久久精品性| 欧洲激情视频| 亚洲欧美清纯在线制服| 97精品视频| 欧美a级在线观看| 日韩成人免费av| 亚洲欧美综合久久久| 国产成人影院| 国产乱人伦丫前精品视频| 久久久天天操| 国产精品毛片| 国产一二三在线| 国产精品xxx| 欧美经典影片视频网站| 日韩一区二区三区在线看| 欧美精品中文| 午夜国产精品视频| 色综合天天爱| 福利一区二区三区视频在线观看| 免费在线亚洲| 日韩电影在线观看电影| 国产精品2023| 一本色道久久综合亚洲精品高清| 91日韩视频| 一区二区三区导航| 亚洲资源网站| 色老板在线视频一区二区| 黄色av日韩| 三上悠亚国产精品一区二区三区 | 亚洲精品成人一区| 亚洲一区二区日韩| 成人综合一区| 噜噜噜91成人网| 成人一区视频| 日本在线中文字幕一区| 久久久久国产精品一区三寸 | 色愁久久久久久| 男人的天堂成人在线| 日本中文字幕一区二区| 91麻豆精品一二三区在线| 久久99国产精品久久99大师| 国产精品入口66mio| 香蕉成人在线| 日韩av系列| 91成人国产| 欧美日韩在线精品一区二区三区激情综合| 日韩精品五月天| 国产欧美啪啪| 93在线视频精品免费观看| 亚洲国产一区二区三区a毛片| jizz久久精品永久免费| 免费欧美在线| 亚洲精品女人| 999久久久精品国产| 中文字幕在线看片| 中文在线日韩| 综合久久成人| 免费成人美女在线观看.| 久久精品999| 99久久人爽人人添人人澡| 香蕉成人久久| 一区二区三区日本视频| 久久精品国产68国产精品亚洲| 在线天堂中文资源最新版| 国产成人三级| 亚洲一卡久久| 中文字幕一区二区精品区| 亚洲视频综合| 国产精品一国产精品k频道56| 欧美三区不卡| 漫画在线观看av| 天堂99x99es久久精品免费| 国产精品腿扒开做爽爽爽挤奶网站| 久久精品久久综合| 久久九九国产| 久久av影院| 久久久久久黄| 日韩成人综合网| 久久婷婷丁香| 久久激情五月激情| 激情欧美日韩| 国产精品xvideos88| 午夜片欧美伦| 中文不卡在线| 麻豆91精品| 亚洲区小说区图片区qvod按摩| 在线综合欧美| 亚洲精品456| 国产精品久久久久9999赢消| 偷拍自拍一区| av在线中出| 精品日产乱码久久久久久仙踪林| 四虎4545www国产精品| 久久久水蜜桃av免费网站| 国产一区精品福利| 伊人情人综合网| 欧洲精品99毛片免费高清观看| 久久午夜精品| 一区二区网站| 中文字幕日本一区二区| 99久久这里只有精品| 麻豆国产精品777777在线| 在线看片不卡| 亚洲欧美校园春色| 日韩欧美一区免费| 久久精品欧美一区| 亚洲中无吗在线| www在线观看黄色| 麻豆国产欧美一区二区三区r| 一区二区激情| 丝瓜av网站精品一区二区| 99精品中文字幕在线不卡 | 国产亚洲精品精品国产亚洲综合| 欧美日韩国产高清电影| 欧美精品大片| 日韩国产一区二区| 亚洲国产综合在线看不卡| av在线亚洲一区| 日韩午夜电影网| 欧美特黄一级| 99久久免费精品国产72精品九九 | av综合电影网站| 欧美影院三区| 亚洲婷婷伊人| 一区二区国产精品| 国产精品久久久久9999赢消| 噜噜噜狠狠夜夜躁精品仙踪林| 影音先锋一区| 欧美xxxhd| 一区在线免费观看| 91亚洲无吗| 亚洲精品一二| 性欧美videohd高精| 99香蕉国产精品偷在线观看| 伊人久久影院| 国产精品免费精品自在线观看| 欧美中文字幕精在线不卡| 黄色精品网站| 久久久亚洲人| 天堂va欧美ⅴa亚洲va一国产|