Пример #1
0
        public Schedule(string schedule)
        {
            OriginalText = schedule;

            var parser = new Parser(schedule);
            var ast = parser.Parse();

            var validator = new Validator(schedule, ast);
            validator.AssertValid();

            _ir = IrBuilder.CompileAst(ast);
        }
Пример #2
0
        /// <summary>
        /// This method assumes the AST is valid and makes absolutely no attempt to further validate any node.
        /// </summary>
        /// <param name="program"></param>
        /// <returns></returns>
        public static IrProgram CompileAst(ProgramNode program)
        {
            var ir = new IrProgram();

            // free-floating expressions are placed in an implicit group
            var irGroup = CompileGroup(program.Expressions);
            if (irGroup != null)
                ir.Groups.Add(irGroup);

            // compile all groups
            foreach (var groupNode in program.Groups)
            {
                irGroup = CompileGroup(groupNode.Expressions);
                if (irGroup != null)
                    ir.Groups.Add(irGroup);
            }

            return ir;
        }
Пример #3
0
        /// <summary>
        /// This method assumes the AST is valid and makes absolutely no attempt to further validate any node.
        /// </summary>
        /// <param name="program"></param>
        /// <returns></returns>
        public static IrProgram CompileAst(ProgramNode program)
        {
            var ir = new IrProgram();

            // free-floating expressions are placed in an implicit group
            var irGroup = CompileGroup(program.Expressions);

            if (irGroup != null)
            {
                ir.Groups.Add(irGroup);
            }

            // compile all groups
            foreach (var groupNode in program.Groups)
            {
                irGroup = CompileGroup(groupNode.Expressions);
                if (irGroup != null)
                {
                    ir.Groups.Add(irGroup);
                }
            }

            return(ir);
        }