Ejemplo n.º 1
0
        private void ParseMenu(List <SclLexicalLine> lines, int indentCount, SclStatementSequence statementSequence,
                               ref int currentLine)
        {
            SclMenu menu = new Conversation.SclMenu(lines[currentLine].PureText);

            currentLine++;
            indentCount = lines[currentLine].IndentCount;
            while (currentLine < lines.Count && lines[currentLine].IndentCount >= indentCount)
            {
                var line = lines[currentLine];
                if (line.IndentCount == indentCount && line.Kind == SclLineKind.MenuOption)
                {
                    string caption = line.PureText;
                    currentLine++;
                    SclStatementSequence theAnswer = ParseConversation(lines, indentCount + 1, ref currentLine);
                    menu.Options.Add(new SclMenuOption()
                    {
                        Caption  = caption,
                        Contents = theAnswer
                    });
                }
                else
                {
                    throw new Exception("Parse error");
                }
            }
            statementSequence.Statements.Add(menu);
        }
Ejemplo n.º 2
0
        private void ParseConversationLine(List <SclLexicalLine> lines, int atIndent, SclStatementSequence statementSequence,
                                           ref int currentLine)
        {
            SclLexicalLine line = lines[currentLine];

            if (currentLine < lines.Count - 1 && lines[currentLine + 1].IndentCount > atIndent)
            {
                ParseMenu(lines, line.IndentCount, statementSequence, ref currentLine);
            }
            else if (line.Kind == SclLineKind.Command)
            {
                statementSequence.Statements.Add(new SclCommandStatement(line));
                currentLine++;
            }
            else if (line.Kind == SclLineKind.SimpleLine)
            {
                statementSequence.Statements.Add(new SclSimpleLineStatement(line));
                currentLine++;
            }
            else
            {
                throw new Exception("Bad parse.");
            }
        }