Example #1
0
        public void VariableContextSearch()
        {
            LolCodeBlock blk = new LolCodeBlock();
            LolCodeBlock chl_blk = new LolCodeBlock(blk);

            Assert.AreSame(blk, LolCodeBlock.GetNextVariableContext(blk), "same context");
            Assert.AreSame(blk, LolCodeBlock.GetNextVariableContext(chl_blk), "child context");
        }
Example #2
0
        public void VariableUninitialized()
        {
            LolCodeBlock blk = new LolCodeBlock();

            blk.AddVariable("abc");
            LolCodeValue tmp = blk.GetVariable("abc");

            Assert.AreEqual(null, tmp.ValueType);
        }
Example #3
0
        public void VariableSearch()
        {
            LolCodeBlock blk = new LolCodeBlock();
            LolCodeBlock chl_blk = new LolCodeBlock(blk);

            LolCodeValue tmp = (LolCodeValue)10;

            blk.AddVariable("abc");
            blk.SetVariable("abc", tmp);

            Assert.AreSame(tmp, blk.GetVariable("abc"), "set main, get main");
            Assert.AreSame(tmp, chl_blk.GetVariable("abc"), "set main, get child");

            tmp = (LolCodeValue)20;

            chl_blk.AddVariable("def");
            chl_blk.SetVariable("def", tmp);

            Assert.AreSame(tmp, blk.GetVariable("def"), "set child, get main");
            Assert.AreSame(tmp, chl_blk.GetVariable("def"), "set child, get child");
        }
Example #4
0
 public void Dispose()
 {
     main = null;
     Console.SetOut(new StreamWriter(Console.OpenStandardOutput()));
 }
Example #5
0
        private void _runParser(string program)
        {
            sw = new StringWriter();
            Console.SetOut(sw);

            main = new LolCodeBlock();
            tokens = new SlkToken(program, log);
            error = new SlkError(tokens, log);
            action = new SlkAction(tokens, main);
            SlkParser.parse(0, action, tokens, error, log, SlkConstants.NT_LOLCODE_);

            main.Run();
        }
Example #6
0
 internal SlkAction(Scanner scanner, LolCodeBlock program_block)
 {
     _contexts.Push(program_block);
     _scanner = scanner;
 }
Example #7
0
 private void StartBlock()
 {
     LolCodeBlock nb = new LolCodeBlock(_contexts.Peek());
     ((LolCodeBlock) _contexts.Peek()).Add(nb);
     _contexts.Push(nb);
 }