Merge pull request #4203 from karl-zylinski/file-tags-without-comments

Make tags use #+ syntax instead of //+
This commit is contained in:
gingerBill
2024-09-19 12:36:43 +01:00
committed by GitHub
332 changed files with 665 additions and 510 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
//+vet !using-param
#+vet !using-param
package compress_zlib
/*
+1 -1
View File
@@ -1,4 +1,4 @@
//+build amd64
#+build amd64
package aes_hw_intel
import "core:sys/info"
+1 -1
View File
@@ -20,7 +20,7 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//+build amd64
#+build amd64
package aes_hw_intel
import "base:intrinsics"
@@ -20,7 +20,7 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//+build amd64
#+build amd64
package aes_hw_intel
import "base:intrinsics"
@@ -1,4 +1,4 @@
//+build amd64
#+build amd64
package chacha20_simd256
import "base:intrinsics"
@@ -1,4 +1,4 @@
//+build !amd64
#+build !amd64
package chacha20_simd256
import "base:intrinsics"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build amd64
#+build amd64
package aes
import "base:intrinsics"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build amd64
#+build amd64
package aes
import "base:intrinsics"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build amd64
#+build amd64
package aes
import "base:intrinsics"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !amd64
#+build !amd64
package aes
@(private = "file")
+1 -1
View File
@@ -1,4 +1,4 @@
//+build amd64
#+build amd64
package aes
import "core:crypto/_aes/hw_intel"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build freebsd, openbsd, netbsd
#+build freebsd, openbsd, netbsd
package crypto
foreign import libc "system:c"
+7 -7
View File
@@ -1,10 +1,10 @@
//+build !linux
//+build !windows
//+build !openbsd
//+build !freebsd
//+build !netbsd
//+build !darwin
//+build !js
#+build !linux
#+build !windows
#+build !openbsd
#+build !freebsd
#+build !netbsd
#+build !darwin
#+build !js
package crypto
HAS_RAND_BYTES :: false
+2 -2
View File
@@ -1,5 +1,5 @@
//+private file
//+build linux, darwin
#+private file
#+build linux, darwin
package debug_trace
import "base:intrinsics"
+3 -3
View File
@@ -1,6 +1,6 @@
//+build !windows
//+build !linux
//+build !darwin
#+build !windows
#+build !linux
#+build !darwin
package debug_trace
import "base:runtime"
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+build windows
#+private
#+build windows
package debug_trace
import "base:intrinsics"
+2 -2
View File
@@ -1,5 +1,5 @@
//+build js
//+private
#+build js
#+private
package dynlib
_load_library :: proc(path: string, global_symbols := false) -> (Library, bool) {
+2 -2
View File
@@ -1,5 +1,5 @@
//+build linux, darwin, freebsd, openbsd, netbsd
//+private
#+build linux, darwin, freebsd, openbsd, netbsd
#+private
package dynlib
import "core:os"
+2 -2
View File
@@ -1,5 +1,5 @@
//+build windows
//+private
#+build windows
#+private
package dynlib
import win32 "core:sys/windows"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build netbsd, openbsd
#+build netbsd, openbsd
package flags
import "base:runtime"
+2 -2
View File
@@ -1,5 +1,5 @@
//+build !netbsd
//+build !openbsd
#+build !netbsd
#+build !openbsd
package flags
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package flags
import "base:intrinsics"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package flags
import "core:container/bit_array"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package flags
import "base:intrinsics"
+3 -3
View File
@@ -1,6 +1,6 @@
//+private
//+build !netbsd
//+build !openbsd
#+private
#+build !netbsd
#+build !openbsd
package flags
import "core:net"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package flags
@require import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build ignore
#+build ignore
package custom_formatter_example
import "core:fmt"
import "core:io"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package fmt
import "core:bufio"
+3 -3
View File
@@ -1,6 +1,6 @@
//+build !freestanding
//+build !js
//+build !orca
#+build !freestanding
#+build !js
#+build !orca
package fmt
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package core_image_bmp
load :: proc{load_from_bytes, load_from_context}
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !js
#+build !js
package core_image_bmp
import "core:os"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package image
load :: proc{
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !js
#+build !js
package image
import "core:os"
+1 -1
View File
@@ -1,4 +1,4 @@
//+vet !using-stmt
#+vet !using-stmt
package netpbm
import "core:bytes"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package netpbm
load :: proc {
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !js
#+build !js
package netpbm
import "core:os"
+1 -1
View File
@@ -8,7 +8,7 @@
*/
//+vet !using-stmt
#+vet !using-stmt
package png
import "core:compress"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package png
load :: proc{load_from_bytes, load_from_context}
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !js
#+build !js
package png
import "core:os"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package qoi
save :: proc{save_to_buffer}
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !js
#+build !js
package qoi
import "core:os"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package tga
save :: proc{save_to_buffer}
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !js
#+build !js
package tga
import "core:os"
+2 -2
View File
@@ -1,5 +1,5 @@
//+build !freestanding
//+build !orca
#+build !freestanding
#+build !orca
package log
import "core:encoding/ansi"
+1 -1
View File
@@ -7,7 +7,7 @@
The code started out as an idiomatic source port of libTomMath, which is in the public domain, with thanks.
*/
//+build ignore
#+build ignore
package math_big
import "core:time"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !js
#+build !js
package math
import "base:intrinsics"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build js
#+build js
package math
import "base:intrinsics"
+1 -1
View File
@@ -4,7 +4,7 @@
Ported from https://github.com/KdotJPG/OpenSimplex2.
Copyright 2022 Yuki2 (https://github.com/NoahR02)
*/
//+private
#+private
package math_noise
/*
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !freestanding
#+build !freestanding
package mem
import "core:sync"
+1 -1
View File
@@ -1,4 +1,4 @@
//+build !freestanding
#+build !freestanding
package mem
import "base:runtime"
+2 -2
View File
@@ -1,5 +1,5 @@
//+build linux
//+private
#+build linux
#+private
package mem_virtual
import "core:sys/linux"
+7 -7
View File
@@ -1,10 +1,10 @@
//+private
//+build !darwin
//+build !freebsd
//+build !openbsd
//+build !netbsd
//+build !linux
//+build !windows
#+private
#+build !darwin
#+build !freebsd
#+build !openbsd
#+build !netbsd
#+build !linux
#+build !windows
package mem_virtual
_reserve :: proc "contextless" (size: uint) -> (data: []byte, err: Allocator_Error) {
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package mem_virtual
Platform_Memory_Block :: struct {
+2 -2
View File
@@ -1,5 +1,5 @@
//+build darwin, netbsd, freebsd, openbsd
//+private
#+build darwin, netbsd, freebsd, openbsd
#+private
package mem_virtual
import "core:sys/posix"
+2 -2
View File
@@ -1,5 +1,5 @@
//+build windows
//+private
#+build windows
#+private
package mem_virtual
foreign import Kernel32 "system:Kernel32.lib"
+1 -1
View File
@@ -1,4 +1,4 @@
// +build windows, linux, darwin, freebsd
#+build windows, linux, darwin, freebsd
package net
/*
+1 -1
View File
@@ -1,4 +1,4 @@
// +build windows, linux, darwin, freebsd
#+build windows, linux, darwin, freebsd
package net
/*
+1 -1
View File
@@ -1,4 +1,4 @@
// +build windows, linux, darwin, freebsd
#+build windows, linux, darwin, freebsd
package net
/*
+1 -1
View File
@@ -1,4 +1,4 @@
//+build linux, darwin, freebsd
#+build linux, darwin, freebsd
package net
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,4 +1,4 @@
//+build windows
#+build windows
package net
/*
+1 -1
View File
@@ -1,5 +1,5 @@
#+build darwin
package net
// +build darwin
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,4 +1,4 @@
//+build freebsd
#+build freebsd
package net
/*
+1 -1
View File
@@ -1,5 +1,5 @@
#+build linux
package net
// +build linux
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,5 +1,5 @@
#+build windows
package net
// +build windows
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,4 +1,4 @@
// +build windows, linux, darwin, freebsd
#+build windows, linux, darwin, freebsd
package net
/*
+1 -1
View File
@@ -1,5 +1,5 @@
#+build darwin
package net
//+build darwin
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,4 +1,4 @@
//+build freebsd
#+build freebsd
package net
/*
+1 -1
View File
@@ -1,5 +1,5 @@
#+build linux
package net
//+build linux
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,5 +1,5 @@
#+build windows
package net
//+build windows
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,4 +1,4 @@
// +build windows, linux, darwin, freebsd
#+build windows, linux, darwin, freebsd
package net
/*
+1 -1
View File
@@ -1,5 +1,5 @@
#+build darwin
package net
// +build darwin
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,4 +1,4 @@
//+build freebsd
#+build freebsd
package net
/*
+1 -1
View File
@@ -1,5 +1,5 @@
#+build linux
package net
// +build linux
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1 -1
View File
@@ -1,5 +1,5 @@
#+build windows
package net
// +build windows
/*
Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures.
+1
View File
@@ -69,6 +69,7 @@ File :: struct {
fullpath: string,
src: string,
tags: [dynamic]tokenizer.Token,
docs: ^Comment_Group,
pkg_decl: ^Package_Decl,
+29 -10
View File
@@ -51,7 +51,7 @@ get_build_arch_from_string :: proc(str: string) -> runtime.Odin_Arch_Type {
parse_file_tags :: proc(file: ast.File, allocator := context.allocator) -> (tags: File_Tags) {
context.allocator = allocator
if file.docs == nil {
if file.docs == nil && file.tags == nil {
return
}
@@ -95,11 +95,9 @@ parse_file_tags :: proc(file: ast.File, allocator := context.allocator) -> (tags
build_project_names: [dynamic][]string
defer shrink(&build_project_names)
for comment in file.docs.list {
if len(comment.text) < 3 || comment.text[:2] != "//" {
continue
}
text := comment.text[2:]
parse_tag :: proc(text: string, tags: ^File_Tags, build_kinds: ^[dynamic]Build_Kind,
build_project_name_strings: ^[dynamic]string,
build_project_names: ^[dynamic][]string) {
i := 0
skip_whitespace(text, &i)
@@ -124,7 +122,7 @@ parse_file_tags :: proc(file: ast.File, allocator := context.allocator) -> (tags
groups_loop: for {
index_start := len(build_project_name_strings)
defer append(&build_project_names, build_project_name_strings[index_start:])
defer append(build_project_names, build_project_name_strings[index_start:])
for {
skip_whitespace(text, &i)
@@ -143,10 +141,10 @@ parse_file_tags :: proc(file: ast.File, allocator := context.allocator) -> (tags
}
scan_value(text, &i)
append(&build_project_name_strings, text[name_start:i])
append(build_project_name_strings, text[name_start:i])
}
append(&build_project_names, build_project_name_strings[index_start:])
append(build_project_names, build_project_name_strings[index_start:])
}
case "build":
kinds_loop: for {
@@ -156,7 +154,7 @@ parse_file_tags :: proc(file: ast.File, allocator := context.allocator) -> (tags
arch_positive: runtime.Odin_Arch_Types
arch_negative: runtime.Odin_Arch_Types
defer append(&build_kinds, Build_Kind{
defer append(build_kinds, Build_Kind{
os = (os_positive == {} ? runtime.ALL_ODIN_OS_TYPES : os_positive) -os_negative,
arch = (arch_positive == {} ? runtime.ALL_ODIN_ARCH_TYPES : arch_positive)-arch_negative,
})
@@ -200,6 +198,27 @@ parse_file_tags :: proc(file: ast.File, allocator := context.allocator) -> (tags
}
}
if file.docs != nil {
for comment in file.docs.list {
if len(comment.text) < 3 || comment.text[:2] != "//" {
continue
}
text := comment.text[2:]
parse_tag(text, &tags, &build_kinds, &build_project_name_strings, &build_project_names)
}
}
for tag in file.tags {
if len(tag.text) < 3 || tag.text[:2] != "#+" {
continue
}
// Only skip # because parse_tag skips the plus
text := tag.text[1:]
parse_tag(text, &tags, &build_kinds, &build_project_name_strings, &build_project_names)
}
tags.build = build_kinds[:]
tags.build_project_name = build_project_names[:]
+1 -3
View File
@@ -77,9 +77,7 @@ parse_package :: proc(pkg: ^ast.Package, p: ^Parser = nil) -> bool {
if !parse_file(p, file) {
ok = false
}
if file.pkg_decl == nil {
error(p, p.curr_tok.pos, "Expected a package declaration at the start of the file")
} else if pkg.name == "" {
if pkg.name == "" {
pkg.name = file.pkg_decl.name
} else if pkg.name != file.pkg_decl.name {
error(p, file.pkg_decl.pos, "different package name, expected '%s', got '%s'", pkg.name, file.pkg_decl.name)
+28 -3
View File
@@ -161,11 +161,36 @@ parse_file :: proc(p: ^Parser, file: ^ast.File) -> bool {
docs := p.lead_comment
p.file.pkg_token = expect_token(p, .Package)
if p.file.pkg_token.kind != .Package {
return false
invalid_pre_package_token: Maybe(tokenizer.Token)
for p.curr_tok.kind != .Package && p.curr_tok.kind != .EOF {
if p.curr_tok.kind == .Comment {
consume_comment_groups(p, p.prev_tok)
} else if p.curr_tok.kind == .File_Tag {
append(&p.file.tags, p.curr_tok)
advance_token(p)
} else {
if invalid_pre_package_token == nil {
invalid_pre_package_token = p.curr_tok
}
advance_token(p)
}
}
if p.curr_tok.kind != .Package {
t := invalid_pre_package_token.? or_else p.curr_tok
error(p, t.pos, "Expected a package declaration at the start of the file")
return false
}
p.file.pkg_token = expect_token(p, .Package)
if ippt, ok := invalid_pre_package_token.?; ok {
error(p, ippt.pos, "Expected only comments or lines starting with '#+' before the package declaration")
return false
}
pkg_name := expect_token_after(p, .Ident, "package")
if pkg_name.kind == .Ident {
switch name := pkg_name.text; {
+2
View File
@@ -32,6 +32,7 @@ Token_Kind :: enum u32 {
Invalid,
EOF,
Comment,
File_Tag,
B_Literal_Begin,
Ident, // main
@@ -166,6 +167,7 @@ tokens := [Token_Kind.COUNT]string {
"Invalid",
"EOF",
"Comment",
"FileTag",
"",
"identifier",
+20
View File
@@ -206,6 +206,23 @@ scan_comment :: proc(t: ^Tokenizer) -> string {
return string(lit)
}
scan_file_tag :: proc(t: ^Tokenizer) -> string {
offset := t.offset - 1
for t.ch != '\n' {
if t.ch == '/' {
next := peek_byte(t, 0)
if next == '/' || next == '*' {
break
}
}
advance_rune(t)
}
return string(t.src[offset : t.offset])
}
scan_identifier :: proc(t: ^Tokenizer) -> string {
offset := t.offset
@@ -636,6 +653,9 @@ scan :: proc(t: ^Tokenizer) -> Token {
if t.ch == '!' {
kind = .Comment
lit = scan_comment(t)
} else if t.ch == '+' {
kind = .File_Tag
lit = scan_file_tag(t)
}
case '/':
kind = .Quo
+1 -1
View File
@@ -1,4 +1,4 @@
//+build darwin, linux, netbsd, freebsd, openbsd
#+build darwin, linux, netbsd, freebsd, openbsd
package os
import "core:strings"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
Read_Directory_Iterator_Impl :: struct {
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+build darwin, netbsd, freebsd, openbsd
#+private
#+build darwin, netbsd, freebsd, openbsd
package os2
import "core:sys/posix"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+build darwin, netbsd, freebsd, openbsd
#+private
#+build darwin, netbsd, freebsd, openbsd
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import win32 "core:sys/windows"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "core:sys/linux"
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+build darwin, netbsd, freebsd, openbsd
#+private
#+build darwin, netbsd, freebsd, openbsd
package os2
import "core:sys/posix"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+build darwin, netbsd, freebsd, openbsd
#+private
#+build darwin, netbsd, freebsd, openbsd
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+build openbsd
#+private
#+build openbsd
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "base:runtime"
+1 -1
View File
@@ -1,4 +1,4 @@
//+private
#+private
package os2
import "core:sys/linux"
+2 -2
View File
@@ -1,5 +1,5 @@
//+private
//+build darwin, netbsd, freebsd, openbsd
#+private
#+build darwin, netbsd, freebsd, openbsd
package os2
import "base:runtime"

Some files were not shown because too many files have changed in this diff Show More