#136: Start working on database persistence

This commit is contained in:
TwinProduction
2021-07-12 00:56:30 -04:00
committed by Chris
parent e6335da94f
commit bd1eb7c61b
657 changed files with 2190821 additions and 82 deletions

11
vendor/modernc.org/opt/AUTHORS generated vendored Normal file
View File

@ -0,0 +1,11 @@
# This file lists authors for copyright purposes. This file is distinct from
# the CONTRIBUTORS files. See the latter for an explanation.
#
# Names should be added to this file as:
# Name or Organization <email address>
#
# The email address is not required for organizations.
#
# Please keep the list sorted.
Jan Mercl <0xjnml@gmail.com>

9
vendor/modernc.org/opt/CONTRIBUTORS generated vendored Normal file
View File

@ -0,0 +1,9 @@
# This file lists people who contributed code to this repository. The AUTHORS
# file lists the copyright holders; this file lists people.
#
# Names should be added to this file like so:
# Name <email address>
#
# Please keep the list sorted.
Jan Mercl <0xjnml@gmail.com>

27
vendor/modernc.org/opt/LICENSE generated vendored Normal file
View File

@ -0,0 +1,27 @@
Copyright (c) 2019 The Opt Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the names of the authors nor the names of the
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

81
vendor/modernc.org/opt/Makefile generated vendored Normal file
View File

@ -0,0 +1,81 @@
# Copyright 2019 The Opt Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
.PHONY: all bench clean cover cpu editor internalError later mem nuke todo edit devbench
grep=--include=*.go --include=*.l --include=*.y --include=*.yy
ngrep='internalError\|TODOOK\|lexer\.go\|parser\.go\|ast.go\|trigraphs\.go\|.*_string\.go\|stringer\.go\|testdata\/gcc'
all:
date
go version 2>&1 | tee log
./unconvert.sh
gofmt -l -s -w *.go
go test -i
go test 2>&1 | tee -a log
go install -v ./...
GOOS=linux GOARCH=arm go build
GOOS=linux GOARCH=386 go build
GOOS=linux GOARCH=amd64 go build
GOOS=windows GOARCH=386 go build
GOOS=windows GOARCH=amd64 go build
go vet 2>&1 | grep -v $(ngrep) || true
golint 2>&1 | grep -v $(ngrep) || true
make todo
misspell *.go
staticcheck | grep -v 'lexer\.go\|parser\.go' || true
maligned || true
grep -n 'FAIL\|PASS' log
go version
date 2>&1 | tee -a log
devbench:
date 2>&1 | tee log-devbench
go test -timeout 24h -dev -run @ -bench . 2>&1 | tee -a log-devbench
grep -n 'FAIL\|SKIP' log-devbench || true
bench:
date 2>&1 | tee log-bench
go test -timeout 24h -v -run '^[^E]' -bench . 2>&1 | tee -a log-bench
grep -n 'FAIL\|SKIP' log-bench || true
clean:
go clean
rm -f *~ *.test *.out
cover:
t=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
cpu: clean
go test -run @ -bench . -cpuprofile cpu.out
go tool pprof -lines *.test cpu.out
edit:
touch log
gvim -p Makefile *.go &
editor:
gofmt -l -s -w *.go
go test -i
go test -short 2>&1 | tee log
go install
later:
@grep -n $(grep) LATER * || true
@grep -n $(grep) MAYBE * || true
mem: clean
go test -v -run ParserCS -memprofile mem.out -timeout 24h
go tool pprof -lines -web -alloc_space *.test mem.out
nuke: clean
go clean -i
todo:
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
@grep -nr $(grep) 'TODO\|panic' * | grep -v $(ngrep) || true
@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true
@grep -nir $(grep) 'work.*progress' || true

11
vendor/modernc.org/opt/README.md generated vendored Normal file
View File

@ -0,0 +1,11 @@
# opt
Package opt implements command-line flag parsing.
### Installation
$ go get [-u] modernc.org/opt
### Documentation
[godoc.org/modernc.org/opt](http://godoc.org/modernc.org/opt)

3
vendor/modernc.org/opt/go.mod generated vendored Normal file
View File

@ -0,0 +1,3 @@
module modernc.org/opt
go 1.13

152
vendor/modernc.org/opt/opt.go generated vendored Normal file
View File

@ -0,0 +1,152 @@
// Package opt implements command-line flag parsing.
package opt // import "modernc.org/opt"
import (
"fmt"
"strings"
)
type opt struct {
handler func(opt, arg string) error
name string
arg bool // Enable argument, e.g. `-I foo` or `-I=foo`
}
// A Set represents a set of defined options.
type Set struct {
cfg map[string]*opt
imm []*opt
}
// NewSet returns a new, empty option set.
func NewSet() *Set { return &Set{cfg: map[string]*opt{}} }
// Opt defines a simple option, e.g. `-f`. When the option is found during
// Parse, the handler is called with the value of the option, e.g. "-f".
func (p *Set) Opt(name string, handler func(opt string) error) {
p.cfg[name] = &opt{
handler: func(opt, arg string) error { return handler(opt) },
}
}
// Arg defines a simple option with an argument, e.g. `-I foo` or `-I=foo`.
// Setting imm argument enables additionally `-Ifoo`. When the option is found
// during Parse, the handler is called with the values of the option and the
// argument, e.g. "-I" and "foo" for all of the variants.
func (p *Set) Arg(name string, imm bool, handler func(opt, arg string) error) {
switch {
case imm:
p.imm = append(p.imm, &opt{
handler: handler,
name: name,
})
default:
p.cfg[name] = &opt{
arg: true,
handler: handler,
name: name,
}
}
}
// Parse parses opts. Must be called after all options are defined. The handler
// is called for all items in opts that were not defined before using Opt or
// Arg.
//
// If any handler returns a non-nil error, Parse will stop. If the error is of
// type Skip, the error returned by Parse will contain all the unprocessed
// items of opts.
//
// The opts slice must not be modified by any handler while Parser is
// executing.
func (p *Set) Parse(opts []string, handler func(string) error) (err error) {
defer func() {
switch err.(type) {
case Skip:
err = Skip(opts)
}
}()
for len(opts) != 0 {
opt := opts[0]
opts = opts[1:]
var arg string
out:
switch {
case strings.HasPrefix(opt, "-"):
name := opt[1:]
for _, cfg := range p.imm {
if strings.HasPrefix(name, cfg.name) {
switch {
case name == cfg.name:
if len(opts) == 0 {
return fmt.Errorf("missing argument of %s", opt)
}
if err = cfg.handler(opt, opts[0]); err != nil {
return err
}
opts = opts[1:]
default:
if err = cfg.handler(opt[:len(cfg.name)+1], name[len(cfg.name):]); err != nil {
return err
}
}
break out
}
}
if n := strings.IndexByte(opt, '='); n > 0 {
arg = opt[n+1:]
name = opt[1:n]
opt = opt[:n]
}
switch cfg := p.cfg[name]; {
case cfg == nil:
if err = handler(opt); err != nil {
return err
}
default:
switch {
case cfg.arg:
switch {
case arg != "":
if err = cfg.handler(opt, arg); err != nil {
return err
}
default:
if len(opts) == 0 {
return fmt.Errorf("missing argument of %s", opt)
}
if err = cfg.handler(opt, opts[0]); err != nil {
return err
}
opts = opts[1:]
}
default:
if err = cfg.handler(opt, ""); err != nil {
return err
}
}
}
default:
if opt == "" {
break
}
if err = handler(opt); err != nil {
return err
}
}
}
return nil
}
// Skip is an error that contains all unprocessed items passed to Parse.
type Skip []string
func (s Skip) Error() string { return fmt.Sprint([]string(s)) }

4
vendor/modernc.org/opt/unconvert.sh generated vendored Normal file
View File

@ -0,0 +1,4 @@
until unconvert -fastmath . &> /dev/null
do
unconvert -fastmath -apply . &> /dev/null
done