成功测试identifier和Punctutation , 增加界符;

This commit is contained in:
Guan Inf 2025-06-03 21:45:03 +08:00
parent 7eb6630248
commit dbb1abdcd5
4 changed files with 62 additions and 61 deletions

View File

@ -263,51 +263,52 @@ a = point {x:24, y:43};
#### 界符表 #### 界符表
| id | 关键字 | | id | 关键字 |
| ------ | ------ | |----|------|
| 1 | - | | 1 | - |
| 2 | | | 2 | |
| 3 | ~ | | 3 | ~ |
| 4 | / | | 4 | / |
| 5 | * | | 5 | * |
| 6 | % | | 6 | % |
| 7 | + | | 7 | + |
| 8 | - | | 8 | - |
| 9 | << | | 9 | << |
| 10 | >> | | 10 | >> |
| 11 | > | | 11 | > |
| 12 | >= | | 12 | >= |
| 13 | < | | 13 | < |
| 14 | <= | | 14 | <= |
| 15 | == | | 15 | == |
| 16 | != | | 16 | != |
| 17 | & | | 17 | & |
| 18 | ^ | | 18 | ^ |
| 19 | \| | | 19 | \| |
| 20 | && | | 20 | && |
| 21 | \|\| | | 21 | \|\| |
| 22 | = | | 22 | = |
| 23 | %= | | 23 | %= |
| 24 | \*= | | 24 | \*= |
| 25 | /= | | 25 | /= |
| 26 | += | | 26 | += |
| 27 | -= | | 27 | -= |
| 28 | \|= | | 28 | \|= |
| 29 | &= | | 29 | &= |
| 30 | ^= | | 30 | ^= |
| 31 | <<= | | 31 | <<= |
| 32 | >>= | | 32 | >>= |
| 33 | ( | | 33 | ( |
| 34 | ) | | 34 | ) |
| 35 | < | | 35 | < |
| 36 | > | | 36 | > |
| 37 | , | | 37 | , |
| 38 | . | | 38 | . |
| 39 | [ | | 39 | [ |
| 40 | ] | | 40 | ] |
| 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

@ -8,7 +8,7 @@ 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 = "a += b b<<=casd;";
Scanner scan(src, tables); Scanner scan(src, tables);
scan.scan(); scan.scan();
@ -18,13 +18,13 @@ TEST_CASE("Scanner test identifier table") {
} }
TEST_CASE("Scanner test Punct table") { // TEST_CASE("Scanner test Punct table") {
Tbs tables = {}; // Tbs tables = {};
std::string src = "+=---<<=>>>===--((([]--<<<>."; // std::string src = "+=---<<=>>>===--((([]--<<<>.";
Scanner scan(src, tables); // Scanner scan(src, tables);
scan.scan(); // scan.scan();
std::cout<<"test\n"; // std::cout<<"test\n";
for (auto e : scan.get_token_list()) { // for (auto e : scan.get_token_list()) {
std::cout<<e.id<<" "<<e.type<<" "<<tables.PunctTable[e.id]<<"\n"; // std::cout<<e.id<<" "<<e.type<<" "<<tables.PunctTable[e.id]<<"\n";
} // }
} // }