move hide behind @ and specify with :
This commit is contained in:
@@ -1758,7 +1758,7 @@ configure_entry_point :: proc(checker: ^Checker) {
|
||||
checker.template_diagnostics[main_template] = source.add(
|
||||
checker.diagnostics,
|
||||
main.span,
|
||||
"@std/io does not provide the required 'hide system func() Io' startup implementation",
|
||||
"@std/io does not provide the required '@hide system func() Io' startup implementation",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ keyword_kind :: proc(text: string) -> token.Kind {
|
||||
case "distinct": return .Keyword_Distinct
|
||||
case "alias": return .Keyword_Alias
|
||||
case "import": return .Keyword_Import
|
||||
case "hide": return .Keyword_Hide
|
||||
case "return": return .Keyword_Return
|
||||
case "try": return .Keyword_Try
|
||||
case "catch": return .Keyword_Catch
|
||||
|
||||
+20
-14
@@ -65,20 +65,21 @@ collect_local_names :: proc(parser: ^Parser) {
|
||||
depth += 1
|
||||
case .Right_Brace:
|
||||
depth = max(depth-1, 0)
|
||||
case .Keyword_Hide:
|
||||
if depth != 0 {
|
||||
case .At:
|
||||
if depth != 0 || index+1 >= len(parser.tokens.items) ||
|
||||
parser.tokens.items[index+1].kind != .Identifier ||
|
||||
token_text(parser, parser.tokens.items[index+1]) != "hide" {
|
||||
continue
|
||||
}
|
||||
visibility := types.Visibility.Package
|
||||
name_index := index+1
|
||||
name_index := index+2
|
||||
if name_index < len(parser.tokens.items) &&
|
||||
parser.tokens.items[name_index].kind == .Left_Paren {
|
||||
if index+4 >= len(parser.tokens.items) ||
|
||||
parser.tokens.items[index+2].kind != .Identifier ||
|
||||
parser.tokens.items[index+3].kind != .Right_Paren {
|
||||
parser.tokens.items[name_index].kind == .Colon {
|
||||
if index+3 >= len(parser.tokens.items) ||
|
||||
parser.tokens.items[index+3].kind != .Identifier {
|
||||
continue
|
||||
}
|
||||
scope := token_text(parser, parser.tokens.items[index+2])
|
||||
scope := token_text(parser, parser.tokens.items[index+3])
|
||||
if scope == "file" {
|
||||
visibility = .File
|
||||
} else if scope != "package" {
|
||||
@@ -86,6 +87,10 @@ collect_local_names :: proc(parser: ^Parser) {
|
||||
}
|
||||
name_index = index+4
|
||||
}
|
||||
for name_index < len(parser.tokens.items) &&
|
||||
parser.tokens.items[name_index].kind == .Newline {
|
||||
name_index += 1
|
||||
}
|
||||
if name_index < len(parser.tokens.items) &&
|
||||
parser.tokens.items[name_index].kind == .Identifier {
|
||||
append(&parser.local_names, Local_Name{
|
||||
@@ -3324,12 +3329,15 @@ parse_test :: proc(parser: ^Parser, name: token.Token) {
|
||||
|
||||
parse_top_level :: proc(parser: ^Parser) {
|
||||
modifier := current(parser)
|
||||
hide_name := peek(parser)
|
||||
visibility := types.Visibility.Public
|
||||
has_modifier := modifier.kind == .Keyword_Hide
|
||||
has_modifier := modifier.kind == .At && hide_name.kind == .Identifier &&
|
||||
token_text(parser, hide_name) == "hide"
|
||||
if has_modifier {
|
||||
visibility = .Package
|
||||
advance(parser)
|
||||
if _, scoped := allow(parser, .Left_Paren); scoped {
|
||||
advance(parser)
|
||||
if _, scoped := allow(parser, .Colon); scoped {
|
||||
if current(parser).kind == .Identifier {
|
||||
scope := advance(parser)
|
||||
scope_text := token_text(parser, scope)
|
||||
@@ -3344,12 +3352,10 @@ parse_top_level :: proc(parser: ^Parser) {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
source.add(parser.diagnostics, current(parser).span, "expected 'package' or 'file' in hide scope")
|
||||
}
|
||||
if _, closed := allow(parser, .Right_Paren); !closed {
|
||||
source.add(parser.diagnostics, current(parser).span, "expected ')' after hide scope")
|
||||
source.add(parser.diagnostics, current(parser).span, "expected 'package' or 'file' after '@hide:'")
|
||||
}
|
||||
}
|
||||
skip_newlines(parser)
|
||||
}
|
||||
if current(parser).kind == .Keyword_Test && peek(parser).kind == .Keyword_Import {
|
||||
if has_modifier {
|
||||
|
||||
@@ -175,7 +175,7 @@ append_runner :: proc(
|
||||
for entry, index in tests {
|
||||
test := module.functions[entry.function]
|
||||
alias := fmt.tprintf("__brolang_test_%d", index)
|
||||
fmt.sbprintf(&builder, "hide __brolang_test_adapter_%d func() void ! __brolang_testing.Error ", index)
|
||||
fmt.sbprintf(&builder, "@hide __brolang_test_adapter_%d func() void ! __brolang_testing.Error ", index)
|
||||
strings.write_string(&builder, "{\n\t")
|
||||
fmt.sbprintf(&builder, "%s.%s() catch |_| ", alias, symbol.resolve(symbols, test.name))
|
||||
strings.write_string(&builder, "{\n\t\treturn .expectation_failed\n\t}\n}\n\n")
|
||||
|
||||
@@ -72,7 +72,6 @@ Kind :: enum u8 {
|
||||
Keyword_Distinct,
|
||||
Keyword_Alias,
|
||||
Keyword_Import,
|
||||
Keyword_Hide,
|
||||
Keyword_Return,
|
||||
Keyword_Try,
|
||||
Keyword_Catch,
|
||||
|
||||
Reference in New Issue
Block a user