grammar

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 7 Imported by: 0

README

grammar

import "github.com/tfadeyi/slotalk/internal/parser/specification/sloth/grammar"

Package grammar contains the grammar rules and lexer related to sloth

Index

Variables

var (
    ErrMissingRequiredField = errors.New("missing required application field(s)")
    ErrParseSource          = errors.New("error parsing source material")
)

func Eval

func Eval(source string, options ...participle.ParseOption) (*sloth.Spec, error)

Eval evaluates the source input against the grammar and returns an instance of *sloth.spec

type Grammar

Grammar is the participle grammar use to parse the Sloth comment groups in source files

type Grammar struct {
    // Stmts is a list of Sloth grammar Statements
    Stmts []*Statement `@@*`
}

type Scope

Scope defines the statement scope, similar to a code function

type Scope struct {
    // Type is the specification struct a statement refers to
    Type  string `(Sloth @((".alerting"(".page"|".ticket")?|".sli"|".slo"))?)`
    Value string `Whitespace* @("service"|"version"|"error_query"|"total_query"|"error_ratio_query"|"name"|"description"|"objective"|"labels"|"annotations"|"disable")`
}
func (Scope) GetType
func (k Scope) GetType() string

GetType returns the type of the statement scope

type Statement

Statement is any comment starting with @sloth keyword

type Statement struct {
    Scope Scope  `@@`
    Value string `Whitespace* @(String (Whitespace|EOL)*)+`
}

Generated by gomarkdoc

Documentation

Overview

Package grammar contains the grammar rules and lexer related to sloth

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingRequiredField = errors.New("missing required application field(s)")
	ErrParseSource          = errors.New("error parsing source material")
)

Functions

func Eval

func Eval(source string, options ...participle.ParseOption) (*sloth.Spec, error)

Eval evaluates the source input against the grammar and returns an instance of *sloth.spec

Types

type Grammar

type Grammar struct {
	// Stmts is a list of Sloth grammar Statements
	Stmts []*Statement `@@*`
}

Grammar is the participle grammar use to parse the Sloth comment groups in source files

type Scope

type Scope struct {
	// Type is the specification struct a statement refers to
	Type  string `(Sloth @((".alerting"(".page"|".ticket")?|".sli"|".slo"))?)`
	Value string `` /* 148-byte string literal not displayed */
}

Scope defines the statement scope, similar to a code function

func (Scope) GetType

func (k Scope) GetType() string

GetType returns the type of the statement scope

type Statement

type Statement struct {
	Scope Scope  `@@`
	Value string `Whitespace* @(String (Whitespace|EOL)*)+`
}

Statement is any comment starting with @sloth keyword

Jump to

Keyboard shortcuts

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