grammar

package
v0.24.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Overview

Player input parsing.

Index

Constants

This section is empty.

Variables

View Source
var Z_Types = typeinfo.TypeSet{
	Name: "grammar",
	Comment: []string{
		"Player input parsing.",
	},

	Slot:       z_slot_list,
	Flow:       z_flow_list,
	Signatures: z_signatures,
}

package listing of type data

View Source
var Zt_Action typeinfo.Flow

action, a type of flow.

View Source
var Zt_ChooseOne typeinfo.Flow

choose_one, a type of flow.

View Source
var Zt_Directive typeinfo.Flow

directive, a type of flow.

View Source
var Zt_Focus typeinfo.Flow

focus, a type of flow.

View Source
var Zt_Noun typeinfo.Flow

noun, a type of flow.

View Source
var Zt_Refine typeinfo.Flow

refine, a type of flow.

View Source
var Zt_Reverse typeinfo.Flow

reverse, a type of flow.

View Source
var Zt_ScannerMaker = typeinfo.Slot{
	Name: "scanner_maker",
	Markup: map[string]any{
		"--": "Commands which interpret player input.",
	},
}

scanner_maker, a type of slot.

View Source
var Zt_Sequence typeinfo.Flow

sequence, a type of flow.

View Source
var Zt_Words typeinfo.Flow

words, a type of flow.

Functions

func Register added in v0.24.7

func Register(reg func(any))

gob like registration

Types

type Action

type Action struct {
	ActionName string
	Arguments  []call.Arg
	Markup     map[string]any `json:",omitempty"`
}

Run a script defined action. The action will be parameterized with the actor performing the action, and up to two other nouns. The actor is always the player's, the nouns are whichever were matched by Noun. This command usually appears last in a series of sub-scanners, after all of the earlier scanners have successfully matched.

func (*Action) GetMarkup

func (op *Action) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Action) MakeScanner

func (op *Action) MakeScanner() parser.Scanner

func (*Action) TypeInfo

func (*Action) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Action_Slice

type Action_Slice []Action

Holds a slice of type Action.

func (*Action_Slice) Repeats

func (op *Action_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Action.

func (*Action_Slice) TypeInfo

func (*Action_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Action.

type ChooseOne

type ChooseOne struct {
	Options []ScannerMaker
	Markup  map[string]any `json:",omitempty"`
}

Attempts to match exactly one of its sub-scanners. Its sub-scanners are evaluated in the order listed; stopping after the first successful match has occurred.

func (*ChooseOne) GetMarkup

func (op *ChooseOne) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*ChooseOne) MakeScanner

func (op *ChooseOne) MakeScanner() (ret parser.Scanner)

func (*ChooseOne) TypeInfo

func (*ChooseOne) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type ChooseOne_Slice

type ChooseOne_Slice []ChooseOne

Holds a slice of type ChooseOne.

func (*ChooseOne_Slice) Repeats

func (op *ChooseOne_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of ChooseOne.

func (*ChooseOne_Slice) TypeInfo

func (*ChooseOne_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of ChooseOne.

type Directive

type Directive struct {
	Name   string
	Series []ScannerMaker
	Markup map[string]any `json:",omitempty"`
}

Starts a parser scanner. This is generated by story statement "DefineNamedGrammar" so that grammar doesn't have to import weave.

func (*Directive) GetMarkup

func (op *Directive) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Directive) MakeScanners

func (op *Directive) MakeScanners() (ret parser.Scanner)

acts as AllOf{Words, ... }

func (*Directive) TypeInfo

func (*Directive) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Directive_Slice

type Directive_Slice []Directive

Holds a slice of type Directive.

func (*Directive_Slice) Repeats

func (op *Directive_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Directive.

func (*Directive_Slice) TypeInfo

func (*Directive_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Directive.

type Focus

type Focus struct {
	Player string
	Series []ScannerMaker
	Markup map[string]any `json:",omitempty"`
}

Select a specific set of bounds for the scanner to use when matching nouns. Currently, the set of scanners is defined in golang, and cannot be extended by script. They are:

  • "" - the empty string for the current locale ( the default bounds )
  • "compass" - for nouns of kind "directions" ( north, east, etc. )
  • "player" - for the player's inventory
  • "debugging" - for all objects of kind "objects"

see: https://pkg.go.dev/git.sr.ht/~ionous/tapestry/support/play#Survey

func (*Focus) GetMarkup

func (op *Focus) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Focus) MakeScanner

func (op *Focus) MakeScanner() parser.Scanner

tbd: i wonder if this should have children ( like any/one of ) rather than being "inline"

func (*Focus) TypeInfo

func (*Focus) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Focus_Slice

type Focus_Slice []Focus

Holds a slice of type Focus.

func (*Focus_Slice) Repeats

func (op *Focus_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Focus.

func (*Focus_Slice) TypeInfo

func (*Focus_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Focus.

type Noun

type Noun struct {
	Kind   string
	Markup map[string]any `json:",omitempty"`
}

Attempt to find a noun matching one or more words entered by the player. Out of all the nouns in a game world the specific nouns matched will, by default, depend on what objects are visible to the player.

func (*Noun) GetMarkup

func (op *Noun) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Noun) MakeScanner

func (op *Noun) MakeScanner() parser.Scanner

func (*Noun) TypeInfo

func (*Noun) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Noun_Slice

type Noun_Slice []Noun

Holds a slice of type Noun.

func (*Noun_Slice) Repeats

func (op *Noun_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Noun.

func (*Noun_Slice) TypeInfo

func (*Noun_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Noun.

type Refine

type Refine struct {
	Series []ScannerMaker
	Markup map[string]any `json:",omitempty"`
}

Uses the last noun in a series of sub-scanners as a source for finding for the first noun in the series. For example, in the phrase "take book from table" if there was one book on a table, and many books on a bookshelf, refine would ensure that the book on the table was selected.

func (*Refine) GetMarkup

func (op *Refine) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Refine) MakeScanner

func (op *Refine) MakeScanner() parser.Scanner

func (*Refine) TypeInfo

func (*Refine) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Refine_Slice

type Refine_Slice []Refine

Holds a slice of type Refine.

func (*Refine_Slice) Repeats

func (op *Refine_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Refine.

func (*Refine_Slice) TypeInfo

func (*Refine_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Refine.

type Reverse

type Reverse struct {
	Reverses []ScannerMaker
	Markup   map[string]any `json:",omitempty"`
}

Assuming that the first and last sub-scanners in a set match nouns, reverse the order of those nouns when sending them to an action.

func (*Reverse) GetMarkup

func (op *Reverse) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Reverse) MakeScanner

func (op *Reverse) MakeScanner() parser.Scanner

func (*Reverse) TypeInfo

func (*Reverse) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Reverse_Slice

type Reverse_Slice []Reverse

Holds a slice of type Reverse.

func (*Reverse_Slice) Repeats

func (op *Reverse_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Reverse.

func (*Reverse_Slice) TypeInfo

func (*Reverse_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Reverse.

type ScannerMaker

type ScannerMaker interface{ MakeScanner() parser.Scanner }

ScannerMaker - creates parser scanners

type ScannerMaker_Slot

type ScannerMaker_Slot struct{ Value ScannerMaker }

Holds a single slot.

func (*ScannerMaker_Slot) TypeInfo

func (*ScannerMaker_Slot) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a single slot.

type ScannerMaker_Slots

type ScannerMaker_Slots []ScannerMaker

Holds a slice of slots.

func (*ScannerMaker_Slots) Repeats

func (op *ScannerMaker_Slots) Repeats() bool

Implements typeinfo.Repeats for a slice of slots.

func (*ScannerMaker_Slots) TypeInfo

func (*ScannerMaker_Slots) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of slots.

type Sequence

type Sequence struct {
	Series []ScannerMaker
	Markup map[string]any `json:",omitempty"`
}

Require that all of its sub-scanners match.

func (*Sequence) GetMarkup

func (op *Sequence) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Sequence) MakeScanner

func (op *Sequence) MakeScanner() (ret parser.Scanner)

func (*Sequence) TypeInfo

func (*Sequence) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Sequence_Slice

type Sequence_Slice []Sequence

Holds a slice of type Sequence.

func (*Sequence_Slice) Repeats

func (op *Sequence_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Sequence.

func (*Sequence_Slice) TypeInfo

func (*Sequence_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Sequence.

type Words

type Words struct {
	Words  []string
	Markup map[string]any `json:",omitempty"`
}

Match text exactly as typed by the player. To match two words that must appear together use a Sequence containing two separate word commands. For example, to match the phrase "take off", use:

Sequence:
  - One word: "take"
  - One word: "off"

func (*Words) GetMarkup

func (op *Words) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Words) MakeScanner

func (op *Words) MakeScanner() parser.Scanner

func (*Words) TypeInfo

func (*Words) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Words_Slice

type Words_Slice []Words

Holds a slice of type Words.

func (*Words_Slice) Repeats

func (op *Words_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Words.

func (*Words_Slice) TypeInfo

func (*Words_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Words.

Jump to

Keyboard shortcuts

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