Skip to content

Commit

Permalink
if
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Chen committed Nov 1, 2023
1 parent f04c7f8 commit 6460366
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
9 changes: 9 additions & 0 deletions doc/windows_qemu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# QEMU创建windows arm64 linux / openwrt

### openwrt官方文档
https://openwrt.org/docs/guide-user/virtualization/qemu

### command
```
"C:\Program Files\qemu\qemu-system-aarch64" -machine virt -cpu cortex-a57 -m 1024 -drive file=ubuntu-23.04-amd64.iso,index=0,media=disk,format=raw -device virtio-net,netdev=net0 -netdev user,id=net0
```
4 changes: 4 additions & 0 deletions src/Token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum Token : int {
tok_assign_type = -16,

tok_result = -17,
tok_if = -18,
};

class Tokenizer {
Expand Down Expand Up @@ -110,6 +111,9 @@ class Tokenizer {
if (identifier == "var") {
return Token::tok_var;
}
if (identifier == "if") {
return Token::tok_if;
}
return Token::tok_identifier;
}

Expand Down
8 changes: 2 additions & 6 deletions tests/cases/binaryExpression.pas
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
program Hello;
var a:Integer;
var b:Integer;
var c:Integer;
var d:Integer;
begin
a := 11;
b := 22;
c := 42;
d := (a+(c-b));
writeln(d);
b := 42;
Result := (a+b);
end.
9 changes: 9 additions & 0 deletions tests/cases/if.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
program Hello;
var i:Integer;
begin
i := 1;
if i = 1 then
begin
writeln(i);
end;
end.
6 changes: 3 additions & 3 deletions tests/e2e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ template <typename T> void printAssemblyMachineCode(T &&runtime) {
}

TEST(compiler_e2e, parser) {
std::ifstream t(workspace / "tests" / "cases" / "return.pas");
std::ifstream t(workspace / "tests" / "cases" / "if.pas");
std::stringstream buffer;
buffer << t.rdbuf();
Tokenizer tokenizer(buffer.str());
Expand All @@ -53,8 +53,8 @@ TEST(compiler_e2e, parser) {
auto program = parser.parse();
auto fun = createJitInt(program->codegen());
std::cout << "ptr: " << std::hex << (void *)fun << std::endl;
const int result = fun();
std::cout << std::dec << result << std::endl;
// const int result = fun();
// std::cout << std::dec << result << std::endl;
// printAssemblyMachineCode(program->codegen());
}

Expand Down

0 comments on commit 6460366

Please sign in to comment.