Example #1
0
        public static Block Not(Block expression)
        {
            var builder = new CodeBuilder();

            builder.Verb(new Not());
            builder.Parenthesize(expression);
            return(builder.Block);
        }
Example #2
0
        public static IMaybe <(Block, bool)> OperatorBlock(Verb verb)
        {
            var builder = new CodeBuilder();

            builder.Variable(DefaultParameterNames.VAR_VALUE1);
            builder.Verb(verb);
            builder.Variable(DefaultParameterNames.VAR_VALUE2);
            return((builder.Block, verb.LeftToRight).Some());
        }
Example #3
0
        public static void GatherToEnd(Block block, ref int index, CodeBuilder builder)
        {
            var count = block.Count;

            for (var i = index; i < count; i++)
            {
                var verb = block.AsAdded[i];
                if (verb is End)
                {
                    return;
                }

                index = i;
                builder.Verb(verb);
            }
        }
Example #4
0
        public static Block GatherToEnd(Block block, ref int index)
        {
            var count   = block.Count;
            var builder = new CodeBuilder();

            for (var i = index; i < count; i++)
            {
                var verb = block.AsAdded[i];
                if (verb is End)
                {
                    return(builder.Block);
                }

                index = i;
                builder.Verb(verb);
            }

            return(builder.Block);
        }
Example #5
0
        void createSourceBlock()
        {
            var asAdded = block.AsAdded;
            var incrementerToBeCreated = true;

            for (var i = 0; i < block.Count; i++)
            {
                var verb = asAdded[i];
                if (FunctionInvoke(block, ref i, out var variableName, out var arguments))
                {
                    if (variableName == functionName)
                    {
                        if (incrementerToBeCreated)
                        {
                            var blocks = arguments.Blocks;
                            var length = blocks.Length;
                            var index  = 0;
                            foreach (var item in allParameterData.TakeWhile(item => index < length))
                            {
                                item.Value.Incrementer = blocks[index++];
                                item.Value.Incrementer.AutoRegister = false;
                            }

                            builder.Variable(functionName);
                            incrementerToBeCreated = false;
                        }
                        else
                        {
                            builder.Variable(variableName);
                        }
                    }
                    else
                    {
                        builder.Verb(verb);
                    }
                }