-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
548 additions
and
660 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
test | ||
.idea | ||
|
||
.DS_Store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package main | |
|
||
import ini "Compiler/src/init" | ||
|
||
// TODO add exception handler | ||
func main() { | ||
ini.Parse() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package doubleLiteral | ||
package literal | ||
|
||
import ( | ||
"Compiler/src/ast/expression/rvalue" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package intLiteral | ||
package literal | ||
|
||
import ( | ||
"Compiler/src/ast/expression/rvalue" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,37 @@ | ||
package stmt | ||
|
||
import ( | ||
"Compiler/src/ast/expression/rvalue" | ||
"Compiler/src/global" | ||
"fmt" | ||
) | ||
|
||
type ScanStmt struct { | ||
Stmt | ||
Expr rvalue.RValue | ||
} | ||
|
||
func (s ScanStmt) GeneCode() { | ||
s.Expr.GeneRVCode() | ||
ir := s.Expr.RvalueIR() | ||
switch s.Expr.GetType() { | ||
case global.INT_LITERAL: | ||
fmt.Printf("call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.scan.int, i32 0, i32 0), i32* %s)\n", ir) | ||
break | ||
case global.DOUBLE_LITERAL: | ||
fmt.Printf("call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.scan.double, i32 0, i32 0), double* %s)\n", ir) | ||
break | ||
case global.CHAR_LITERAL: | ||
p := ir + "_c" | ||
fmt.Printf("call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.scan, i32 0, i32 0), i8* %s)\n", p) | ||
break | ||
default: | ||
break | ||
} | ||
} | ||
|
||
func CreateScanStmt(rhs rvalue.RValue) ScanStmt { | ||
var s ScanStmt | ||
s.Expr = rhs | ||
return s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.