nob 实现最后一步编译框架 移动测试用例 准备for的新语法
This commit is contained in:
1 parent
c4d1bbae92
commit
bb8761d392
92 files changed
+803
-27
No files matched your search
+5
-1
@@ -7,7 +7,7 @@ type .{ .ByteView } = @import("utils/byte_view.spl");
|
||||
|
||||
type Keyword = enum {
|
||||
Any, As, Bool, Break, Catch, Comptime, Const, Continue, Defer, Else, Enum,
|
||||
Errdefer, False, Fn, For, If, Loop, Match, Null, Ret, Shape, Struct, True,
|
||||
Errdefer, False, Fn, For, If, In, Loop, Match, Null, Ret, Shape, Struct, True,
|
||||
Try, Type, Undefined, Union, Var, While, Underscore,
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ fn keyword_of(text: ByteView): KeywordResult {
|
||||
if c0 == 'a' && is(text, "as") { ret .Yes(.As); }
|
||||
if c0 == 'f' && is(text, "fn") { ret .Yes(.Fn); }
|
||||
if c0 == 'i' && is(text, "if") { ret .Yes(.If); }
|
||||
if c0 == 'i' && is(text, "in") { ret .Yes(.In); }
|
||||
ret .No;
|
||||
}
|
||||
if n == 3 {
|
||||
@@ -147,6 +148,7 @@ fn keyword_name(kw: Keyword): []u8 {
|
||||
.Fn => { ret "KW_FN"; },
|
||||
.For => { ret "KW_FOR"; },
|
||||
.If => { ret "KW_IF"; },
|
||||
.In => { ret "KW_IN"; },
|
||||
.Loop => { ret "KW_LOOP"; },
|
||||
.Match => { ret "KW_MATCH"; },
|
||||
.Null => { ret "KW_NULL"; },
|
||||
@@ -259,6 +261,7 @@ fn expect_keyword(result: KeywordResult, expected: Keyword) {
|
||||
|
||||
fn test_keywords() {
|
||||
expect_keyword(keyword_of(view("fn")), .Fn);
|
||||
expect_keyword(keyword_of(view("in")), .In);
|
||||
expect_keyword(keyword_of(view("while")), .While);
|
||||
expect_keyword(keyword_of(view("_")), .Underscore);
|
||||
match keyword_of(view("foo")) {
|
||||
@@ -337,6 +340,7 @@ fn test_kind_names() {
|
||||
expect_kind_name(.Keyword(.Fn), "KW_FN");
|
||||
expect_kind_name(.Keyword(.For), "KW_FOR");
|
||||
expect_kind_name(.Keyword(.If), "KW_IF");
|
||||
expect_kind_name(.Keyword(.In), "KW_IN");
|
||||
expect_kind_name(.Keyword(.Loop), "KW_LOOP");
|
||||
expect_kind_name(.Keyword(.Match), "KW_MATCH");
|
||||
expect_kind_name(.Keyword(.Null), "KW_NULL");
|
||||
|
||||
Reference in new issue
Block a user