// 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); }
// 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); }