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

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

代做Micro Language Compiler

時(shí)間:2024-02-07  來(lái)源:合肥網(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ī)打開(kāi)當(dāng)前頁(yè)
  • 上一篇:COM3524代做、代寫Java,Python編程設(shè)計(jì)
  • 下一篇:CISC3025代做、代寫Java,c++設(shè)計(jì)編程
  • 無(wú)相關(guān)信息
    合肥生活資訊

    合肥圖文信息
    流體仿真外包多少錢_專業(yè)CFD分析代做_友商科技CAE仿真
    流體仿真外包多少錢_專業(yè)CFD分析代做_友商科
    CAE仿真分析代做公司 CFD流體仿真服務(wù) 管路流場(chǎng)仿真外包
    CAE仿真分析代做公司 CFD流體仿真服務(wù) 管路
    流體CFD仿真分析_代做咨詢服務(wù)_Fluent 仿真技術(shù)服務(wù)
    流體CFD仿真分析_代做咨詢服務(wù)_Fluent 仿真
    結(jié)構(gòu)仿真分析服務(wù)_CAE代做咨詢外包_剛強(qiáng)度疲勞振動(dòng)
    結(jié)構(gòu)仿真分析服務(wù)_CAE代做咨詢外包_剛強(qiáng)度疲
    流體cfd仿真分析服務(wù) 7類仿真分析代做服務(wù)40個(gè)行業(yè)
    流體cfd仿真分析服務(wù) 7類仿真分析代做服務(wù)4
    超全面的拼多多電商運(yùn)營(yíng)技巧,多多開(kāi)團(tuán)助手,多多出評(píng)軟件徽y1698861
    超全面的拼多多電商運(yùn)營(yíng)技巧,多多開(kāi)團(tuán)助手
    CAE有限元仿真分析團(tuán)隊(duì),2026仿真代做咨詢服務(wù)平臺(tái)
    CAE有限元仿真分析團(tuán)隊(duì),2026仿真代做咨詢服
    釘釘簽到打卡位置修改神器,2026怎么修改定位在范圍內(nèi)
    釘釘簽到打卡位置修改神器,2026怎么修改定
  • 短信驗(yàn)證碼 豆包網(wǎng)頁(yè)版入口 破天一劍 目錄網(wǎng) 排行網(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

    国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看
    久久久com| 欧美怡春院一区二区三区| 免费在线观看亚洲视频| 亚洲成人一区二区三区| 中文字幕色一区二区| 国产精品久久久久影院日本| 久久精品99| 久久久亚洲国产精品| 国产精品亚洲综合| 青青草视频在线免费播放| 欧美激情亚洲天堂| 国产一区欧美二区三区| 国产精品亚洲不卡a| 久色视频在线播放| 国产精品久久久久久一区二区| 精品久久久久久无码国产| 亚洲中文字幕无码一区二区三区 | 日韩在线免费视频| 亚洲中文字幕无码专区| 青青草综合在线| 91久久国产婷婷一区二区| www日韩欧美| 五码日韩精品一区二区三区视频 | 欧美久久久精品| 五月天亚洲综合情| 日本福利视频一区| 欧美精品与人动性物交免费看| 逼特逼视频在线| 国产专区一区二区三区| 日韩免费观看av| 免费久久99精品国产自| 成人免费无码av| 国产suv精品一区二区三区88区| 久久这里只有精品8| 久久免费视频这里只有精品| 国产成人久久777777| 国产精品久久久久久久久久| 九九热这里只有精品免费看| 日韩在线一级片| 国产欧美一区二区| 久久久久久久久久久免费精品 | 久久大香伊蕉在人线观看热2| 91高清视频免费| 久久久久久久久网| 精品国产乱码久久久久软件| 无码人妻精品一区二区蜜桃百度| 青青草免费在线视频观看| 国产在线拍揄自揄视频不卡99| 91精品视频在线看| 麻豆成人在线看| 日韩中文字幕免费在线| 免费高清在线观看免费| 国产精品av电影| 久久av.com| 欧洲亚洲一区二区三区四区五区| 成人做爽爽免费视频| www.xxxx精品| 一区不卡字幕| 蜜桃网站成人| 久久99久久精品国产| 欧美日韩福利在线观看| 欧美日韩在线成人| 国产z一区二区三区| 国产尤物av一区二区三区| 久久精品国产欧美亚洲人人爽| 伊人色综合久久天天五月婷| 欧美大陆一区二区| 日韩中文字幕不卡视频| 日本高清视频一区二区三区| 99国产在线观看| 中文字幕一区二区三区四区五区六区 | 国产精品入口免费视频一| 欧美精品在线免费| 欧美亚洲一级二级| 久久99精品久久久久子伦| 亚洲7777| 国产xxx69麻豆国语对白| 精品久久久久久久久久中文字幕 | 亚洲啪啪av| 99国精产品一二二线| 亚洲欧洲精品一区二区| 91九色视频在线| 中文字幕在线亚洲三区| 91精品视频免费| 日本一区二区三区精品视频| 国产成人手机视频| 欧美日韩在线观看一区| 国产精品激情av在线播放| 粉嫩av一区二区三区天美传媒| 欧美激情第1页| 国产福利一区二区三区在线观看| 欧美亚洲一二三区| 国产精品日韩一区| 国产在线999| 午夜精品蜜臀一区二区三区免费| 国产成人精品免高潮在线观看| 欧美 日韩 国产 在线观看| 中文字幕色一区二区| 久久精品美女| 极品尤物一区二区三区| 欧美日本亚洲视频| 国产经典久久久| 欧美主播一区二区三区美女 久久精品人| 国产精品日韩在线播放| 97公开免费视频| 免费毛片一区二区三区久久久| 亚洲一区二区精品在线| 国产精品高清在线观看| 欧美一级免费视频| 在线观看一区欧美| 国产精品久久久久福利| 色一情一乱一伦一区二区三区| 中国成人亚色综合网站| 国产精品久久久久99| 国产成人综合亚洲| 国产亚洲天堂网| 日韩欧美视频网站| 欧美激情精品久久久久久蜜臀| 久久99国产精品一区| 国产精品av一区| 97精品久久久中文字幕免费| 国产日本欧美一区二区三区| 亚洲国产日韩美| 亚洲一区二区三区色| 中文一区一区三区免费| 精品国产aⅴ麻豆| 久久国产精品影视| 久久国产精品99国产精| 久久精品视频免费播放| 欧美一级二级三级| 欧美在线一二三区| 日韩久久精品一区二区三区| 成人做爰www免费看视频网站| 色综合久久久888| 一区二区不卡视频| 春色成人在线视频| 三级三级久久三级久久18| 欧美一区二区视频在线| 天堂√在线观看一区二区| 天天干天天色天天爽| 日本va中文字幕| 韩国欧美亚洲国产| 国产精品制服诱惑| 国产成人一区二区三区小说| 日韩综合中文字幕| 国产精品第一页在线| 国产精品久久久久9999| 国产精品成人国产乱一区| 亚洲一区二区精品在线| 精品少妇在线视频| 麻豆乱码国产一区二区三区| 精品久久久久久无码中文野结衣| 一道本在线观看视频| 欧美日韩精品免费看| 国产精品香蕉av| 国产精品久久久一区| 视频一区在线免费观看| 欧美性久久久久| 久久免费一级片| 成人做爰www免费看视频网站| 国内外免费激情视频| 成人av.网址在线网站| 久久精品国产精品青草色艺| 欧美成年人在线观看| 日韩精品不卡| 久久人人爽人人爽人人片av高请| 久久久国产在线视频| 日韩精品在线视频免费观看| 久久香蕉视频网站| 亚洲精品中文综合第一页| 国产麻花豆剧传媒精品mv在线| 九九九久久久| 欧美在线一级va免费观看| 久久久婷婷一区二区三区不卡| 影音先锋欧美在线| 国产日韩中文字幕| 欧美激情伊人电影| 国产一区二区网| 国产99视频精品免视看7| 国产日产精品一区二区三区四区| 国产精品电影网站| 成人免费在线小视频| 久久国产精品久久久久久| 国产一区二区视频免费在线观看| 欧美激情亚洲自拍| www.亚洲一区| 91久久大香伊蕉在人线| 欧美一区二区三区四区夜夜大片| 久久综合伊人77777尤物| 国产高清精品软男同| 国产精品香蕉在线观看| 国产福利成人在线| 精品伦精品一区二区三区视频| 福利视频一二区| 日本不卡二区| 中文精品无码中文字幕无码专区| 色播五月综合| 亚洲在线视频观看| 国产成人小视频在线观看| 91免费国产网站|