Merge remote-tracking branch 'origin/main'

# Conflicts:
#	unit/scanner_test.cpp
This commit is contained in:
Gary Gan 2025-06-03 21:58:32 +08:00
commit 0bcec890a0
4 changed files with 52 additions and 62 deletions

View File

@ -264,7 +264,7 @@ a = point {x:24, y:43};
#### 界符表 #### 界符表
| id | 关键字 | | id | 关键字 |
| ------ | ------ | |----|------|
| 1 | - | | 1 | - |
| 2 | | | 2 | |
| 3 | ~ | | 3 | ~ |
@ -308,6 +308,7 @@ a = point {x:24, y:43};
| 41 | ? | | 41 | ? |
| 42 | : | | 42 | : |
| 43 | -> | | 43 | -> |
| 44 | : |
#### 常量表 #### 常量表
@ -329,14 +330,13 @@ a = point {x:24, y:43};
### Hydrogen样例 ### Hydrogen样例
```Hydrogen ```Hydrogen
struct Point { struct Point {
x:i8; x:i8;
y:i8; y:i8;
} }
[Point:105] tmp; [Point:105] tmp;
fn MergeSort([Point:20] v,i8 l,i8 r) -> { fn MergeSort([Point:20] v,i8 l,i8 r) -> {
if l>r { if l>r {
return ; return ;

View File

@ -76,7 +76,8 @@ public:
{40, "]"}, {40, "]"},
{41, "?"}, {41, "?"},
{42, ":"}, {42, ":"},
{43, "->"} {43, "->"},
{44,";"}
}; };
}; };

View File

@ -5,7 +5,7 @@
#include "Tbs.h" #include "Tbs.h"
#include <vector> #include <vector>
using std::string,std::vector; using std::string,std::vector;
//
TEST_CASE("Scanner test identifier table") { TEST_CASE("Scanner test identifier table") {
Tbs tables; Tbs tables;
std::string src = "abcvljl laadfs fafarwrw"; std::string src = "abcvljl laadfs fafarwrw";
@ -28,14 +28,3 @@ TEST_CASE("Scanner test Punct table") {
std::cout<<e.id<<" "<<e.type<<" "<<tables.PunctTable[e.id]<<"\n"; std::cout<<e.id<<" "<<e.type<<" "<<tables.PunctTable[e.id]<<"\n";
} }
} }
TEST_CASE("Scanner test key table") {
Tbs tables = {};
std::string src = "i32";
Scanner scan(src, tables);
scan.scan();
std::cout<<"test\n";
for (auto e : scan.get_token_list()) {
std::cout<<e.id<<" "<<e.type <<"\n";
}
}