示例#1
0
        public void Keyword()
        {
            string top = Peek().Value;

            if (!Env.Commands.ContainsKey(top))
            {
                throw new MissingDefinitionException($"Unknown keyword: {top}");
            }

            ICmd cmd = Env.Commands[top];

            if (!InScript && !cmd.IsGlobal)
            {
                throw new ScopeException($"Cannot execute {top} in global context");
            }

            if (InScript && !cmd.IsScript)
            {
                throw new ScopeException($"Cannot execute {top} in script context");
            }

            Consume();
            cmd.Apply(this, ConsumeArguments(cmd));
        }