Skip to content

Instantly share code, notes, and snippets.

View bradford-hamilton's full-sized avatar

Bradford Lamson-Scribner bradford-hamilton

View GitHub Profile
package dora
import (
"fmt"
"strconv"
)
// The available accessTypes for a dora query
const (
ObjectAccess accessType = iota
package main
import (
"fmt"
"github.com/bradford-hamilton/dora/pkg/dora"
)
const testJSONObject = `{
"item1": ["aryitem1", "aryitem2", {"some": {"thing": "coolObj"}}],
// Package ast TODO: package docs
package ast
// These are the available root node types. In JSON it will either be an
// object or an array at the base.
const (
ObjectRoot RootNodeType = iota
ArrayRoot
)
// Package parser TODO
package parser
import (
"errors"
"fmt"
"strconv"
"strings"
"github.com/bradford-hamilton/dora/pkg/ast"
<JSON> ::= <value>
<value> ::= <object> | <array> | <boolean> | <string> | <number> | <null>
<array> ::= "[" [ <value> *(', ' <value>) ] "]"
<object> ::= "{" [ <property> *(', ' <property>) ] "}"
<property> ::= <string> ":" <value>
package lexer
import (
"github.com/bradford-hamilton/dora/pkg/token"
)
// Lexer performs lexical analysis/scanning of the JSON
type Lexer struct {
Input []rune
char rune // current char under examination
// All the different tokens for supporting JSON
const (
// Token/character we don't know about
Illegal Type = "ILLEGAL"
// End of file
EOF Type = "EOF"
// Literals
String Type = "STRING"
@bradford-hamilton
bradford-hamilton / token.go
Created April 17, 2020 14:01
This is currently what a token in dora looks like
// Token is a struct representing a JSON token - It holds information like its Type and Literal, as well
// as Start, End, and Line fields. Line is used for better error handling, while Start and End are used
// to return objects/arrays from querys.
type Token struct {
Type Type
Literal string
Line int
Start int
End int
}
@bradford-hamilton
bradford-hamilton / skynet-s3-connection-example.go
Created March 8, 2020 19:18
Example connection with my QNAP NAS s3 compatible object-store in Go
package main
import (
"fmt"
"os"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
package main
import (
"fmt"
"reflect"
"strconv"
"testing"
)
// benchmarkisPointerTypeAssertion 31.2 ns/op