parser

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2019 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Database       *Database    `"DATABASE" @@`
	Roles          *Roles       `| "ROLES" @@`
	Extensions     *Extensions  `| "EXTENSIONS" @@`
	Schemas        *Schemas     `| "SCHEMAS" @@`
	ForeignKeys    *ForeignKeys `| ("FOREIGN" "KEYS") @@`
	Schema         *Name        `| "SCHEMA" @@`
	TablesInSchema *Name        `| "TABLES" "IN" @@`
	ViewsInSchema  *Name        `| "VIEWS" "IN" @@`
	Table          *SchemaItem  `| "TABLE" @@`
	View           *SchemaItem  `| "VIEW" @@`
	Indexes        *SchemaItem  `| "INDEXES" "ON" @@`
	Constraints    *SchemaItem  `| "CONSTRAINTS" "ON" @@`
}

Command contains details of a create or drop command. Only one of the members will be `true` or populated.

type DDSL

type DDSL struct {
	Create  *Command     `"CREATE" @@`
	Drop    *Command     `| "DROP" @@`
	Migrate *Migrate     `| "MIGRATE" @@`
	Sql     *string      `| "SQL" @Sql`
	Seed    *SeedCommand `| "SEED" @@`
}

DDSL is the top level struct of the parser. Only one of the members will be populated.

func Parse

func Parse(commands string) ([]*DDSL, error)

Parse parses an input of one or more commands and returns a slice of parse trees.

type Database

type Database struct {
	Ref *Ref `[@@]`
}

Database contains details for action on a database.

type Extensions

type Extensions struct {
	Ref *Ref `[@@]`
}

Extensions contains details for action on extensions.

type ForeignKeys

type ForeignKeys struct {
	Ref *Ref `[@@]`
}

ForeignKeys contains details for action on a foreign keys.

type Migrate

type Migrate struct {
	Top    bool `@"TOP"`
	Bottom bool `| @"BOTTOM"`
	Up     *int `| "UP" @Int`
	Down   *int `| "DOWN" @Int`
}

Migrate contains the migration command. Only one of the members will be `true` or nonzero.

type Name

type Name struct {
	Name string `@Ident`
	Ref  *Ref   `[@@]`
}

type Ref

type Ref struct {
	Ref string `@Ref`
}

Tag contains the git tag to run the DDSL command against.

type Roles

type Roles struct {
	Ref *Ref `[@@]`
}

Roles contains details for action on roles.

type SchemaItem

type SchemaItem struct {
	Item        string `@SchemaItem`
	Ref         *Ref   `[@@]`
	TableOrView string
	Schema      string
}

SchemaItem contains the schema and table or view when it is the object of the command.

type Schemas

type Schemas struct {
	Ref *Ref `[@@]`
}

Schemas contains details for action on schemas.

type SeedCommand

type SeedCommand struct {
	Table          *SchemaItem `"TABLE" @@`
	TablesInSchema *Name       `| "TABLES" "IN" @@`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL