Example #1
0
        // dialog =
        //		"[" word "]"
        //		string
        //		resp { resp }
        public DialogElement Dialog()
        {
            // acceptera "[" word "]"
            Consume(typeof(DialogBeginToken));
            WordToken dialogNameToken = (WordToken)Consume(typeof(WordToken));

            Consume(typeof(DialogEndToken));

            // accepterar word { " " word }
            string dialogText = String();

            DialogElement dialogElement = new DialogElement(dialogNameToken.Value, dialogText);

            List <DialogResponse> responses = new List <DialogResponse>();

            while (tokens.Current.GetType() == typeof(ResponseToken))
            {
                responses.Add(Response());

                if (tokens.Current == null)
                {
                    break;
                }
            }

            dialogElement.Responses = responses.ToArray();
            return(dialogElement);
        }
Example #2
0
        // resp	=
        //		"#" string "{" word "}"
        public DialogResponse Response()
        {
            Consume(typeof(ResponseToken));
            string responseText = String();

            Consume(typeof(ResponseTargetBeginToken));
            WordToken replyTarget = (WordToken)Consume(typeof(WordToken));

            Consume(typeof(ResponseTargetEndToken));

            DialogResponse response = new DialogResponse(responseText, replyTarget.Value);

            return(response);
        }