Beispiel #1
0
func init() {
	s := term.InitS()
	s = dynamics.ExpectQuestion(s, GetTemplate, "Q", "t")
	s = dynamics.AddSimple(s, term.ViewS(term.Sr("t")))

	t := s.Copy().AppendTemplate(term.Quoted{}.Head())
	t = dynamics.AddSimple(t, term.AskS(Explicit.S(term.Sr("t"))))
	t = dynamics.ExpectAnswer(t, core.Answer, "A", "explicit")
	t = dynamics.AddSimple(t, term.AskS(GetTemplate.S(term.Sr("explicit"))))
	t = dynamics.ExpectAnswer(t, core.Answer, "A2", "result")
	t = dynamics.AddSimple(t, term.ReturnS(core.Answer.S(term.Sr("result"))))

	t = s.Copy().AppendTemplate(QuotedQuoteT, "q")
	dynamics.AddSimple(t, term.ReturnS(core.Answer.S(
		term.Sc(Template(term.Quoted{}.Head())),
	)))

	t = s.Copy().AppendTemplate(QuotedIntT, "q")
	dynamics.AddSimple(t, term.ReturnS(core.Answer.S(
		term.Sc(Template(term.Int(0).Head())),
	)))

	t = s.Copy().AppendTemplate(QuotedStrT, "q")
	dynamics.AddSimple(t, term.ReturnS(core.Answer.S(
		term.Sc(Template(term.Str(0).Head())),
	)))

	t = s.Copy().AppendTemplate(QuotedWrapperT, "q")
	dynamics.AddSimple(t, term.ReturnS(core.Answer.S(
		term.Sc(Template(term.Wrap(nil).Head())),
	)))

	t = s.Copy().AppendTemplate(QuotedCompoundT, "template", "args")
	t = dynamics.AddSimple(t, term.ReturnS(core.Answer.S(term.Sr("template"))))
}
Beispiel #2
0
func Transition(t dynamics.Transition) term.T {
	switch t := t.(type) {
	case dynamics.SimpleTransition:
		return QuotedSimpleTransition.T(ActionC(t.Action))
	case dynamics.NativeTransition:
		return QuotedNativeTransition.T(term.Wrap(t))
	}
	panic("quoting an unknown type of transition")
}