Example #1
0
        public static bool Read(ContextCompiler cc, out UserCommand usercmd)
        {
            usercmd = new UserCommand();
            AbstractWordReader wreader = cc.wreader;

            // command
            while (wreader.CurrentType != WordType.Identifier || wreader.CurrentWord != "command")
            {
                wreader.LetterReader.SetError("command の開始には keyword 'command' が必要です。", 0, null);
                if (!wreader.ReadNext())
                {
                    return(false);
                }
            }
            wreader.ReadNext();

            // CommandName
            while (wreader.CurrentType != WordType.Identifier)
            {
                wreader.LetterReader.SetError("keyword 'context' の後には識別子が必要です。", 0, null);
                if (!wreader.ReadNext())
                {
                    return(false);
                }
            }
            usercmd.name = wreader.CurrentWord;
            wreader.ReadNext();

            // {}
            while (wreader.CurrentType != WordType.Literal)
            {
                wreader.LetterReader.SetError("command 宣言の後には command の中身が必要です。中身は { で始めて下さい。", 0, null);
                if (!wreader.ReadNext())
                {
                    return(false);
                }
            }
            usercmd.content = FormatSource(wreader.CurrentWord);
            wreader.ReadNext();

            return(true);
        }