Skip to content

Commit 628cf7e

Browse files
6heehanisac322
authored andcommitted
v comment
1 parent c63e86f commit 628cf7e

25 files changed

+187
-0
lines changed

.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ TTime_Compiler.iml
6262
doc/*
6363
out/*
6464
*.iml
65+
/bin/

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>TTime</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

src/Syntax/ArrayInit.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ void display(int lev) {
6060
}
6161
}
6262

63+
/**
64+
* void type의 변수가 선언되었는지 확인
65+
* <p>
66+
* 배열의 크기가 양수인지 확인
67+
* <p>
68+
* 초기화가 되어있는 배열이라면 해당 초기화 식을 확인
69+
* <p>
70+
* 배열 크기와 초기화 식의 수를 확인, 초기화 식을 확인하고 type을 확인
71+
*/
6372
@Override
6473
protected void V(HashMap<String, Init> declarationMap) {
6574
// todo 확인

src/Syntax/ArrayRef.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ void display(int lev) {
3636
index.display(lev + 1);
3737
}
3838

39+
/**
40+
* 선언이 되어있는 변수의 이름인지 확인
41+
* <p>
42+
* <tt>ArrayInit</tt>의 객체인지 확인
43+
* <p>
44+
* 참조하려는 배열의 index가 Int인지 확인
45+
*/
3946
@Override
4047
protected void V(HashMap<String, Init> declarationMap) {
4148
// todo 확인 인덱스 범위 확인

src/Syntax/Binary.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ void display(int lev) {
4040
term2.display(lev + 1);
4141
}
4242

43+
/**
44+
* 좌변, 우변의 타당성 검사
45+
* <p>
46+
* 연산자가 = 이라면 좌변이 변수참조인지 확인
47+
* <p>
48+
* 양 변이 void type인지 확인
49+
* <p>
50+
* 변수에 type에 맞게 해당 연산자를 맞게 불러오도록 함
51+
*
52+
*/
4353
@Override
4454
protected void V(HashMap<String, Init> declarationMap) {
4555
if (valid) return;

src/Syntax/Block.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ void display(int lev) {
3232
}
3333
}
3434

35+
/**
36+
* block내의 statement를 확인
37+
*/
3538
@Override
3639
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
3740
if (valid) return;
@@ -43,6 +46,9 @@ protected void V(HashMap<String, Init> declarationMap, Type functionType) {
4346
valid = true;
4447
}
4548

49+
/**
50+
* block내의 반복문이 포함된 statement를 확인
51+
*/
4652
@Override
4753
protected void V(HashMap<String, Init> declarationMap, Statement loopStatement, Type functionType) {
4854
if (valid) return;

src/Syntax/Break.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ void display(int lev) {
2222
System.out.println("Break");
2323
}
2424

25+
/**
26+
* 반복문이 없는 statement에서 break가 나오면 에러
27+
*/
2528
@Override
2629
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
2730
check(false, "wrong statement. break keyword is not to be here");
2831
}
2932

33+
/**
34+
* while, for, switch문에서 break가 쓰이는지 확인
35+
*/
3036
@Override
3137
protected void V(HashMap<String, Init> declarationMap, Statement loopStatement, Type functionType) {
3238
check(loopStatement instanceof WhileStatement

src/Syntax/Continue.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ void display(int lev) {
2222
System.out.println("Continue");
2323
}
2424

25+
/**
26+
* while, for문에서 continue가 쓰이는지 확인
27+
*/
2528
@Override
2629
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
2730
check(false, "wrong statement. continue can not be here");

src/Syntax/Declaration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ void display(int lev) {
3636
}
3737
}
3838

39+
/**
40+
* 선언에 대해서 확인, init V를 호출
41+
*/
3942
@Override
4043
protected void V(HashMap<String, Init> declarationMap) {
4144
for (Init init : inits) {

src/Syntax/ForStatement.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ void display(int lev) {
9898
statements.display(lev + 1);
9999
}
100100

101+
/**
102+
* for문에 조건문이 null이면 에러, 조건문 타입체크
103+
* <p>
104+
* preExpression의 타입체크
105+
* <p>
106+
* postExpression의 타입체크
107+
* <p>
108+
* for문 내의 statements의 타입 체크
109+
*/
101110
@Override
102111
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
103112
if (valid) return;
@@ -123,6 +132,9 @@ protected void V(HashMap<String, Init> declarationMap, Type functionType) {
123132
valid = true;
124133
}
125134

135+
/**
136+
* break, continue의 포함여부를 구분하기 위해 선언
137+
*/
126138
@Override
127139
protected void V(HashMap<String, Init> declarationMap, Statement loopStatement, Type functionType) {
128140
V(declarationMap, functionType);

src/Syntax/Function.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ void display(int lev) {
5454
}
5555
}
5656

57+
/**
58+
* params에 해당하는 식이 타당한지 검사
59+
* <p>
60+
* 타당한 parmas를 paramsType에 추가저장
61+
* <p>
62+
* 해당 함수의 table의 정보를 가져옴
63+
* <p>
64+
* 함수의 리턴타입을 저장
65+
*/
5766
@Override
5867
protected void V(HashMap<String, Init> declarationMap) {
5968
if (valid) return;

src/Syntax/FunctionDeclaration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ void display(int lev) {
9797
statements.display(lev + 1);
9898
}
9999

100+
/**
101+
* global 변수의 table을 가져와 해당 함수의 변수를 table에 추가
102+
* <p>
103+
* 추가된 table의 길이가 맞는지 확인
104+
* <p>
105+
* 함수 내부의 실행문의 v 호출
106+
*/
100107
@Override
101108
protected void V(HashMap<String, Init> declarationMap) {
102109
// todo

src/Syntax/IfStatement.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ void display(int lev) {
8989
}
9090
}
9191

92+
/**
93+
* if문의 조건이 타당한지 검사
94+
* <p>
95+
* 조건문의 타입이 bool인지 검사
96+
* <p>
97+
* if문 내부의 실행문 검사
98+
* <p>
99+
* elseif 구문이 존재한다면 조건과 실행문 검사
100+
* <p>
101+
* else 구문이 존재한다면 실행문 검사
102+
*/
92103
@Override
93104
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
94105
// todo 확인
@@ -122,6 +133,9 @@ protected void V(HashMap<String, Init> declarationMap, Type functionType) {
122133
valid = true;
123134
}
124135

136+
/**
137+
* 반복문 내부에 존재하는 if구문 검사
138+
*/
125139
@Override
126140
protected void V(HashMap<String, Init> declarationMap, Statement loopStatement, Type functionType) {
127141
// todo 확인

src/Syntax/Init.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public void genCode() {
4949
init();
5050
}
5151

52+
/**
53+
* 좌변 우변의 type이 타당한지 검사
54+
* <p>
55+
* 자동 형변환 까지 가능한 경우까지 검사
56+
* @param init
57+
* @param variableType
58+
*/
5259
protected void checkInitType(Expression init, Type variableType) {
5360
if (variableType.equals(Type.FLOAT)) {
5461
check(type.equals(Type.FLOAT) || type.equals(Type.INT),

src/Syntax/NoArrayInit.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ void display(int lev) {
5252
}
5353
}
5454

55+
/**
56+
* void 타입의 변수가 선언되었는지 확인
57+
* <p>
58+
* 초기화 식이 존재한다면 초기화 식 확인
59+
* <p>
60+
* 초기화 식의 type을 확인
61+
*/
5562
@Override
5663
protected void V(HashMap<String, Init> declarationMap) {
5764
// todo 확인

src/Syntax/Operator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ void display(int lev) {
381381
System.out.println("Operator " + value);
382382
}
383383

384+
/**
385+
* 해당 type에 맞는 연산자를 반환
386+
* @param op
387+
* @param type
388+
* @return
389+
*/
384390
public static Operator mapping(Operator op, Type type) {
385391
if (type.equals(Type.INT)) {
386392
return intMap(op.value);

src/Syntax/ParamDeclaration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ void display(int lev) {
2626
System.out.println("ParamDeclaration " + type + " " + name);
2727
}
2828

29+
/**
30+
* 파라미터에 void type이 있는지 확인
31+
*/
2932
@Override
3033
protected void V(HashMap<String, Init> declarationMap) {
3134
// todo 확인

src/Syntax/Program.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ public void validation() {
118118
}
119119

120120

121+
/**
122+
* 외부변수, 함수 선언의 타당성을 확인
123+
* <p>
124+
* main함수의 실행문의 타당성을 확인
125+
*/
121126
@Override
122127
protected void V(HashMap<String, Init> declarationMap) {
123128
for (Global global : globals) {

src/Syntax/Return.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,21 @@ void display(int lev) {
4444
}
4545
}
4646

47+
/**
48+
* 반복문 내에 있는 return문의 타당성 확인
49+
*/
4750
@Override
4851
protected void V(HashMap<String, Init> declarationMap, Statement loopStatement, Type functionType) {
4952
V(declarationMap, functionType);
5053
}
5154

55+
/**
56+
* return value가 있는지 확인
57+
* <p>
58+
* return value가 있다면 type이 void인지 확인, return 식이 타당한지 확인
59+
* <p>
60+
* return value가 없다면 type이 void인지 확인
61+
*/
5262
@Override
5363
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
5464
if (returnValue == null) {

src/Syntax/Statements.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ void display(int lev) {
7272
}
7373
}
7474

75+
/**
76+
* main함수 내의 선언부의 타당성을 확인
77+
* <p>
78+
* main함수 내에서 선언된 변수를 table에 추가
79+
* <p>
80+
* 내부 실행문들의 타당성 확인
81+
*/
7582
@Override
7683
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
7784
// todo

src/Syntax/SwitchStatement.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ void display(int lev) {
101101
}
102102
}
103103

104+
/**
105+
* switch의 조건이 타당한지 확인
106+
* <p>
107+
* 해당 case들의 값이 switch type과 맞는지 확인
108+
* <p>
109+
* case내부의 실행문이 타당한지 확인
110+
* <p>
111+
* default가 존재한다면 실행문이 타당한지 확인
112+
*/
104113
@Override
105114
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
106115
// todo 확인
@@ -128,6 +137,9 @@ protected void V(HashMap<String, Init> declarationMap, Type functionType) {
128137
valid = true;
129138
}
130139

140+
/**
141+
* 반복문 내부에 switch문이 존재할 때 호출하여 타당성 확인
142+
*/
131143
@Override
132144
protected void V(HashMap<String, Init> declarationMap, Statement loopStatement, Type functionType) {
133145
// todo 확인

src/Syntax/TypeCast.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ void display(int lev) {
4040
expression.display(lev + 1);
4141
}
4242

43+
/**
44+
* type cast를 하려는 식의 타당성을 확인
45+
* <p>
46+
* type cast의 변환 타입이 타당한지 확인
47+
*/
4348
@Override
4449
protected void V(HashMap<String, Init> declarationMap) {
4550
// todo 확인

src/Syntax/Variable.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ void display(int lev) {
4747
System.out.println("Variable " + name);
4848
}
4949

50+
/**
51+
* table에 정의되어 있는 변수인지 확안
52+
* <p>
53+
* 배열이 table에 정의 되어있는지 확인
54+
*/
5055
@Override
5156
protected void V(HashMap<String, Init> declarationMap) {
5257
// todo 확인

src/Syntax/WhileStatement.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ void display(int lev) {
3636
statements.display(lev + 1);
3737
}
3838

39+
/**
40+
* while문의 조건문이 타당한지 검사
41+
* <p>
42+
* 조건문의 반환 type이 bool인지 검사
43+
* <p>
44+
* while문 내부의 실행문의 타당성 검사
45+
*/
3946
@Override
4047
protected void V(HashMap<String, Init> declarationMap, Type functionType) {
4148
if (valid) return;
@@ -51,6 +58,9 @@ protected void V(HashMap<String, Init> declarationMap, Type functionType) {
5158
valid = true;
5259
}
5360

61+
/**
62+
* 반복문 내부의 while문의 타당성 검사
63+
*/
5464
@Override
5565
protected void V(HashMap<String, Init> declarationMap, Statement loopStatement, Type functionType) {
5666
V(declarationMap, functionType);

0 commit comments

Comments
 (0)