diff --git a/README.md b/README.md index b2fc96e..b108a7a 100644 --- a/README.md +++ b/README.md @@ -263,51 +263,52 @@ a = point {x:24, y:43}; #### 界符表 -| id | 关键字 | -| ------ | ------ | -| 1 | - | -| 2 | ! | -| 3 | ~ | -| 4 | / | -| 5 | * | -| 6 | % | -| 7 | + | -| 8 | - | -| 9 | << | -| 10 | >> | -| 11 | > | -| 12 | >= | -| 13 | < | -| 14 | <= | -| 15 | == | -| 16 | != | -| 17 | & | -| 18 | ^ | -| 19 | \| | -| 20 | && | -| 21 | \|\| | -| 22 | = | -| 23 | %= | -| 24 | \*= | -| 25 | /= | -| 26 | += | -| 27 | -= | -| 28 | \|= | -| 29 | &= | -| 30 | ^= | -| 31 | <<= | -| 32 | >>= | -| 33 | ( | -| 34 | ) | -| 35 | < | -| 36 | > | -| 37 | , | -| 38 | . | -| 39 | [ | -| 40 | ] | -| 41 | ? | -| 42 | : | -| 43 | -> | +| id | 关键字 | +|----|------| +| 1 | - | +| 2 | ! | +| 3 | ~ | +| 4 | / | +| 5 | * | +| 6 | % | +| 7 | + | +| 8 | - | +| 9 | << | +| 10 | >> | +| 11 | > | +| 12 | >= | +| 13 | < | +| 14 | <= | +| 15 | == | +| 16 | != | +| 17 | & | +| 18 | ^ | +| 19 | \| | +| 20 | && | +| 21 | \|\| | +| 22 | = | +| 23 | %= | +| 24 | \*= | +| 25 | /= | +| 26 | += | +| 27 | -= | +| 28 | \|= | +| 29 | &= | +| 30 | ^= | +| 31 | <<= | +| 32 | >>= | +| 33 | ( | +| 34 | ) | +| 35 | < | +| 36 | > | +| 37 | , | +| 38 | . | +| 39 | [ | +| 40 | ] | +| 41 | ? | +| 42 | : | +| 43 | -> | +| 44 | : | #### 常量表 @@ -329,14 +330,13 @@ a = point {x:24, y:43}; ### Hydrogen样例 ```Hydrogen - struct Point { x:i8; y:i8; } - [Point:105] tmp; + fn MergeSort([Point:20] v,i8 l,i8 r) -> { if l>r { return ; diff --git a/include/Scanner.h b/include/Scanner.h index 6170c97..3e88f48 100644 --- a/include/Scanner.h +++ b/include/Scanner.h @@ -16,10 +16,10 @@ public: int len = 0; for (int i = 0; i < m_source_code.size(); i++) { if (len = process_const_table(i)) { - i += len - 1; + i += len - 1; len = 0; } else if (len = process_identifier_table(i)) { - i += len - 1; + i += len - 1; len = 0; } else if (len = process_key_table(i)) { i += len - 1; diff --git a/include/Tbs.h b/include/Tbs.h index 70c3df1..ffaeb3a 100644 --- a/include/Tbs.h +++ b/include/Tbs.h @@ -76,7 +76,8 @@ public: {40, "]"}, {41, "?"}, {42, ":"}, - {43, "->"} + {43, "->"}, + {44,";"} }; }; diff --git a/unit/scanner_test.cpp b/unit/scanner_test.cpp index 1246e77..3715b0c 100644 --- a/unit/scanner_test.cpp +++ b/unit/scanner_test.cpp @@ -8,7 +8,7 @@ using std::string,std::vector; TEST_CASE("Scanner test identifier table") { Tbs tables; - std::string src = "abcvljl laadfs fafarwrw"; + std::string src = "a += b b<<=casd;"; Scanner scan(src, tables); scan.scan(); @@ -18,13 +18,13 @@ TEST_CASE("Scanner test identifier table") { } -TEST_CASE("Scanner test Punct table") { - Tbs tables = {}; - std::string src = "+=---<<=>>>===--((([]--<<<>."; - Scanner scan(src, tables); - scan.scan(); - std::cout<<"test\n"; - for (auto e : scan.get_token_list()) { - std::cout<