Created
February 24, 2013 14:04
-
-
Save mdaisuke/5023960 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (Directive ".file\t\"hoge.cb\"") | |
| (Directive ".section\t.rodata") | |
| (Label (NamedSymbol ".LC0")) | |
| (Directive ".string\t\"Hello world\n\"") | |
| (Directive ".text") | |
| (Directive ".globl main") | |
| (Directive ".type\tmain,@function") | |
| (Label (NamedSymbol "main")) | |
| (Instruction "push" "l" (Register BP INT32)) | |
| (Instruction "mov" "l" (Register SP INT32) (Register BP INT32)) | |
| (Instruction "mov" "l" (ImmediateValue (NamedSymbol ".LC0")) (Register AX INT32)) | |
| (Instruction "push" "l" (Register AX INT32)) | |
| (Instruction "call" "" (DirectMemoryReference (NamedSymbol "printf"))) | |
| (Instruction "add" "l" (ImmediateValue (IntegerLiteral 4)) (Register SP INT32)) | |
| (Instruction "mov" "l" (ImmediateValue (IntegerLiteral 0)) (Register AX INT32)) | |
| (Instruction "jmp" "" (DirectMemoryReference (UnnamedSymbol @4ca31e1b))) | |
| (Label (UnnamedSymbol @4ca31e1b)) | |
| (Instruction "mov" "l" (Register BP INT32) (Register SP INT32)) | |
| (Instruction "pop" "l" (Register BP INT32)) | |
| (Instruction "ret" "") | |
| (Directive ".size\tmain,.-main") |
This file contains hidden or 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
| <<AST>> (hoge.cb:1) | |
| variables: | |
| functions: | |
| <<DefinedFunction>> (hoge.cb:3) | |
| name: "main" | |
| isPrivate: false | |
| params: | |
| parameters: | |
| body: | |
| <<BlockNode>> (hoge.cb:4) | |
| variables: | |
| stmts: | |
| <<ExprStmtNode>> (hoge.cb:5) | |
| expr: | |
| <<FuncallNode>> (hoge.cb:5) | |
| expr: | |
| <<VariableNode>> (hoge.cb:5) | |
| name: "printf" | |
| args: | |
| <<StringLiteralNode>> (hoge.cb:5) | |
| value: "Hello world\n" | |
| <<ReturnNode>> (hoge.cb:6) | |
| expr: | |
| <<IntegerLiteralNode>> (hoge.cb:6) | |
| typeNode: int | |
| value: 0 |
This file contains hidden or 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
| <<IR>> (hoge.cb:1) | |
| variables: | |
| functions: | |
| <<DefinedFunction>> (hoge.cb:3) | |
| name: main | |
| isPrivate: false | |
| type: int() | |
| body: | |
| <<ExprStmt>> (hoge.cb:5) | |
| expr: | |
| <<Call>> | |
| type: INT32 | |
| expr: | |
| <<Addr>> | |
| type: INT32 | |
| entity: printf | |
| args: | |
| <<Str>> | |
| type: INT32 | |
| entry: net.loveruby.cflat.entity.ConstantEntry@7e5a9de6 | |
| <<Return>> (hoge.cb:6) | |
| expr: | |
| <<Int>> | |
| type: INT32 | |
| value: 0 |
This file contains hidden or 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
| <<AST>> (hoge.cb:1) | |
| variables: | |
| functions: | |
| <<DefinedFunction>> (hoge.cb:3) | |
| name: "main" | |
| isPrivate: false | |
| params: | |
| parameters: | |
| body: | |
| <<BlockNode>> (hoge.cb:4) | |
| variables: | |
| stmts: | |
| <<ExprStmtNode>> (hoge.cb:5) | |
| expr: | |
| <<FuncallNode>> (hoge.cb:5) | |
| expr: | |
| <<VariableNode>> (hoge.cb:5) | |
| type: int(char*)* | |
| name: "printf" (resolved) | |
| args: | |
| <<StringLiteralNode>> (hoge.cb:5) | |
| value: "Hello world\n" | |
| <<ReturnNode>> (hoge.cb:6) | |
| expr: | |
| <<IntegerLiteralNode>> (hoge.cb:6) | |
| typeNode: int (resolved) | |
| value: 0 |
This file contains hidden or 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
| "import" "import" | |
| <SPACES> " " | |
| <IDENTIFIER> "stdio" | |
| ";" ";" | |
| <SPACES> "\n\n" | |
| "int" "int" | |
| <SPACES> " " | |
| <IDENTIFIER> "main" | |
| "(" "(" | |
| "void" "void" | |
| ")" ")" | |
| <SPACES> "\n" | |
| "{" "{" | |
| <SPACES> "\n " | |
| <IDENTIFIER> "printf" | |
| "(" "(" | |
| "\"" "\"Hello world\n\"" | |
| ")" ")" | |
| ";" ";" | |
| <SPACES> "\n " | |
| "return" "return" | |
| <SPACES> " " | |
| <INTEGER> "0" | |
| ";" ";" | |
| <SPACES> "\n" | |
| "}" "}" | |
| <SPACES> "\n" | |
| <EOF> "" |
This file contains hidden or 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
| import stdio; | |
| int main(void) | |
| { | |
| printf("Hello world\n"); | |
| return 0; | |
| } |
This file contains hidden or 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
| .file "hoge.cb" | |
| .section .rodata | |
| .LC0: | |
| .string "Hello world\n" | |
| .text | |
| .globl main | |
| .type main,@function | |
| main: | |
| pushl %ebp | |
| movl %esp, %ebp | |
| movl $.LC0, %eax | |
| pushl %eax | |
| call printf | |
| addl $4, %esp | |
| movl $0, %eax | |
| jmp .L0 | |
| .L0: | |
| movl %ebp, %esp | |
| popl %ebp | |
| ret | |
| .size main,.-main |
This file contains hidden or 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
| .file "hoge.cb" | |
| .section .rodata | |
| .LC0: | |
| .string "Hello world\n" | |
| .text | |
| .globl main | |
| .type main,@function | |
| main: | |
| pushl %ebp | |
| movl %esp, %ebp | |
| movl $.LC0, %eax | |
| pushl %eax | |
| call printf | |
| addl $4, %esp | |
| movl $0, %eax | |
| jmp .L0 | |
| .L0: | |
| movl %ebp, %esp | |
| popl %ebp | |
| ret | |
| .size main,.-main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tokens -> ast -> semantic(checked ast) -> ir -> asm