juice500ml / cminus Goto Github PK
View Code? Open in Web Editor NEWC- Compiler Project for Sogang Univ. (17' Spring)
C- Compiler Project for Sogang Univ. (17' Spring)
but have to change printSymtab
if(test_expr) {
true_stmt;
}
else {
false_stmt;
}
test_expr ; returns to Rsrc
beqz Rsrc, L_false ; if zero, goto L_false
true_stmt ; fallthrough
J L_exit ; exit if-else stmt
L_false:
false_stmt
L_exit:
while(test_expr) {
stmt;
}
J L_cmp ; jump only first time
L_loop:
stmt;
L_cmp:
test_expr ; returns to Rsrc
bnez Rsrc, L_loop
f(arr, var); // array: arr, variable: var
# 1. Parameter pushing: 뒤에서부터 차례대로 sp-4, sp-8, sp-12...
# var: 원본 값을 푸쉬
i = input(); // integer input
output(i); // integer output
.data
newline: .asciiz "\n"
.text
; input
li $v0, 5 ; read_int
syscall ; returns value as int
; output
li $a0, $v0
li $v0, 1 ; print_int
syscall
li $v0, 4 ; print_str
la $a0, newline
syscall
.globl main # Is this necessary?
.text
; Every code ...
내가 테스트케이스 나중에 올려줄테니 고쳐주길 바람. @juice500ml
일단, syntatic analyzer가 잘 도는 testcase들로 project 3를 테스트하고 있겠음.
매우 짜증나는 문제임.
output(100);
output(10);
아래와 같이 출력하라고 되어있다.
Output : 100
Output : 10
Input은 안써있다 ㅡㅡ
조교님한테 메일을 보내던, Input : 도 출력해주던, 해결을 봐야 할 듯.
int input(void);
void output(int);
현재 폴더 구조를 바꿈으로서 make가 작동하지 않음.
+) 그리고 태승이가 원래 makefile 짰던 것 처럼 뭔가 더 다듬어지면 좋을 것 같기도함.
현재 코드가 틀림.
고쳐야 하는 부분:
void codeGen()의 FunctionDeclarationK
int localCodeGen()의 ReturnStatementK
현재 코드는 개판으로 되어있으니, 저 두 부분은 사실상 갈아엎어야 하는데,
localCodeGen()의 type이 int고 parameter으로 stack size를 받는 이유는 그래야지 해당 cmpd stmt에서 스택을 얼마나 썼는지 알 수 있고, return 시점에서 해당 stack을 모두 비울 수 있음
원래는 return 시점마다 stack clean하는 코드가 박히게 되는데, 현재 해당 설계상 이론적으로도 불가능하고, 사실 말도 안됨. 그러므로 현재 구현해야 하는 것은
_var is in AssignExpressionK
https://github.com/juice500ml/compiler-sogang/blob/master/src/analyze.c#L187-L190
왜 TraceAnalyze 변수가 안쓰인거?
static int globalMemAlloc(size) {
// ...
addr += size;
return addr;
}
이게 맞나?
root directory에도 있고, src에도 있는데 왜 그런거??
@taeseunglee
일꾼 : @taeguk
Deadline : 5/27(토) 23:59
–std=iso9899:1999 flag 붙이는게 좋을 듯.
std별로 가능한게 달라서 확실히 픽스해야 할 듯.
Warning 가능한거 다 띄우는게 개발하기 편할 듯.
솔직히 -Wtraditional까지는 필요없는데, 나머지는 흔히 하는 실수들을 컴파일 중에 잡아줄 수 있어서 좋은 듯.
ex) make debug 라고 할 경우 해당 flag 다 붙여서 빌드
–Wall
–pedantic
-Wtraditional
-Wshadow
-Wpointer-arith
-Wcast-qual
-Wcast-align
-Wstrict-prototypes
-Wmissing-prototypes
-Wconversion
어떻게 생각함? @taeguk @taeseunglee
현재 지역변수 fp+memloc 인 경우만 되어잇음
그냥 memloc인 경우도 잇어야 함 (global의 경우)
https://github.com/juice500ml/compiler-sogang/blob/master/src/analyze.c#L504
여기에서 expectedRetType = ErrorT; 를 추가해주는게 나을듯?
int intFunc(void)
{
int a;
if (a)
{
a;
}
}
프로그램 사망.(더블 프리 에러)
st_pop_scope()를 주석처리 해봤더니, a;에서 선언하지 않았다고 함.
그리고
@juice500ml @taeseunglee
typeCheck 부분 구현 부탁.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.