parser

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: GPL-3.0, GPL-3.0 Imports: 15 Imported by: 48

Documentation

Overview

  Parses all the specs in the list of directories given and also de-duplicates all specs passed through `specDirs` before parsing specs.
  Gets all the specs files in the given directory and generates token for each spec file.
  While parsing a concept file, concepts are inlined i.e. concept in the spec file is replaced with steps that concept has in the concept file.
  While creating a specification file parser applies the converter functions.
  Parsing a spec file gives a specification with parseresult. ParseResult contains ParseErrors, CriticalErrors, Warnings and FileName

  Errors can be generated, While
	- Generating tokens
	- Applying converters
	- After Applying converters

  If a parse error is found in a spec, only that spec is ignored and others will continue execution.
  This doesn't invoke the language runner.
  Eg : Multiple spec headings found in same file.
       Scenario should be defined after the spec heading.

  Critical error :
  	Circular reference of concepts - Doesn't parse specs becz it goes in recursion and crashes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToStepText

func ConvertToStepText(fragments []*gauge_messages.Fragment) string

func CreateStepValue

func CreateStepValue(step *gauge.Step) gauge.StepValue

func ExtractStepArgsFromToken added in v0.9.1

func ExtractStepArgsFromToken(stepToken *Token) ([]gauge.StepArg, error)

ExtractStepArgsFromToken extracts step args(Static and Dynamic) from the given step token.

func ExtractStepValueAndParams

func ExtractStepValueAndParams(stepText string, hasInlineTable bool) (*gauge.StepValue, error)

func FilterTableRelatedScenarios added in v0.8.5

func FilterTableRelatedScenarios(scenarios []*gauge.Scenario, fun func(*gauge.Scenario) bool) (otherScenarios, tableRelatedScenarios []*gauge.Scenario)

FilterTableRelatedScenarios filters Scenarios that are using dynamic params from data table.

func GetSpecsForDataTableRows added in v0.8.4

func GetSpecsForDataTableRows(s []*gauge.Specification, errMap *gauge.BuildErrors) (specs []*gauge.Specification)

GetSpecsForDataTableRows creates a spec for each data table row

func GetUnescapedString

func GetUnescapedString(string1 string) string

Gives unescaped string.

func HandleParseResult

func HandleParseResult(results ...*ParseResult) bool

func ParseSpecs added in v0.6.2

func ParseSpecs(args []string, conceptsDictionary *gauge.ConceptDictionary, buildErrors *gauge.BuildErrors) ([]*gauge.Specification, bool)

ParseSpecs parses specs in the give directory and gives specification and pass/fail status, used in validation.

func PopulateConceptDynamicParams

func PopulateConceptDynamicParams(concept *gauge.Step, dataTableLookup *gauge.ArgLookup) error

Creating a copy of the lookup and populating table values

Types

type ConceptParser

type ConceptParser struct {
	// contains filtered or unexported fields
}

func (*ConceptParser) Parse

func (parser *ConceptParser) Parse(text, fileName string) ([]*gauge.Step, *ParseResult)

concept file can have multiple concept headings. Generates token for the given concept file and cretes concepts(array of steps) and parse results.

func (*ConceptParser) ParseFile added in v0.1.8

func (parser *ConceptParser) ParseFile(file string) ([]*gauge.Step, *ParseResult)

Reads file contents from a give file and parses the file.

type ParamResolver

type ParamResolver struct {
}

func (*ParamResolver) GetResolvedParams

func (paramResolver *ParamResolver) GetResolvedParams(step *gauge.Step, parent *gauge.Step, lookup *gauge.ArgLookup) ([]*gauge_messages.Parameter, error)

GetResolvedParams based on the arg type(static, dynamic, table, special_string, special_table) resolves the parameter of a step.

type ParseError

type ParseError struct {
	FileName string
	LineNo   int
	Message  string
	LineText string
}

func AddConcept added in v0.9.4

func AddConcept(concepts []*gauge.Step, file string, conceptDictionary *gauge.ConceptDictionary) ([]ParseError, error)

func AddConcepts

func AddConcepts(conceptFiles []string, conceptDictionary *gauge.ConceptDictionary) ([]*gauge.Step, []ParseError, error)

AddConcepts parses the given concept file and adds each concept to the concept dictionary.

func (ParseError) Error

func (se ParseError) Error() string

Error prints error with filename, line number, error message and step text.

type ParseResult

type ParseResult struct {
	ParseErrors []ParseError
	Warnings    []*Warning
	Ok          bool
	FileName    string
}

func CreateConceptsDictionary

func CreateConceptsDictionary() (*gauge.ConceptDictionary, *ParseResult, error)

CreateConceptsDictionary generates a ConceptDictionary which is map of concept text to concept. ConceptDictionary is used to search for a concept.

func CreateStepUsingLookup added in v0.3.2

func CreateStepUsingLookup(stepToken *Token, lookup *gauge.ArgLookup, specFileName string) (*gauge.Step, *ParseResult)

CreateStepUsingLookup generates gauge steps from step token and args lookup.

func ParseConcepts added in v0.6.2

func ParseConcepts() (*gauge.ConceptDictionary, *ParseResult, error)

ParseConcepts creates concept dictionary and concept parse result.

func ParseSpecFiles

func ParseSpecFiles(specFiles []string, conceptDictionary *gauge.ConceptDictionary, buildErrors *gauge.BuildErrors) ([]*gauge.Specification, []*ParseResult)

TODO: Use single channel instead of one for spec and another for result, so that mapping is consistent ParseSpecFiles - gets all the spec files and parse each spec file. Generates specifications and parse results.

func ValidateConcepts added in v0.9.4

func ValidateConcepts(conceptDictionary *gauge.ConceptDictionary) *ParseResult

func (*ParseResult) Errors added in v0.5.0

func (result *ParseResult) Errors() (errors []string)

Errors Prints parse errors and critical errors.

type SpecParser

type SpecParser struct {
	// contains filtered or unexported fields
}

func (*SpecParser) CreateSpecification

func (parser *SpecParser) CreateSpecification(tokens []*Token, conceptDictionary *gauge.ConceptDictionary, specFile string) (*gauge.Specification, *ParseResult, error)

CreateSpecification creates specification from the given set of tokens.

func (*SpecParser) GenerateTokens

func (parser *SpecParser) GenerateTokens(specText, fileName string) ([]*Token, []ParseError)

Generates tokens based on the parsed line.

func (*SpecParser) Parse

func (parser *SpecParser) Parse(specText string, conceptDictionary *gauge.ConceptDictionary, specFile string) (*gauge.Specification, *ParseResult, error)

Parse generates tokens for the given spec text and creates the specification.

func (*SpecParser) ParseSpecText added in v0.9.4

func (parser *SpecParser) ParseSpecText(specText string, specFile string) (*gauge.Specification, *ParseResult)

ParseSpecText without validating and replacing concepts.

type Token

type Token struct {
	Kind     gauge.TokenKind
	LineNo   int
	LineText string
	Suffix   string
	Args     []string
	Value    string
}

func (*Token) String

func (token *Token) String() string

type Warning

type Warning struct {
	FileName string
	LineNo   int
	Message  string
}

func (*Warning) String

func (warning *Warning) String() string

Jump to

Keyboard shortcuts

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