Ejemplo n.º 1
0
        private Statements ReadIfs(Statements statements)
        {
            // 1. Find first .IF
            var firstIf = statements.FirstOrDefault(statement => statement is Control c && c.Name.ToLower() == "if");

            if (firstIf == null)
            {
                return(statements);
            }

            var firstIfIndex = statements.IndexOf(firstIf);
            var result       = (Statements)statements.Clone();

            // 2. Find matching .ENDIF
            var matchedEndIfIndex = FindFirstMatched(result, firstIfIndex + 1, "endif");

            if (matchedEndIfIndex == statements.Count)
            {
                Validation.Reading.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Error, "Cannot find matched .endif"));
                return(result);
            }

            // 3. Compute result of .if
            var ifResultStatements = ComputeIfResult(result, firstIfIndex, matchedEndIfIndex);

            // 4.Replace .if statements with its result
            result.Replace(firstIfIndex, matchedEndIfIndex, ifResultStatements);

            // 5. Do it again.
            result = ReadIfs(result);

            return(result);
        }
Ejemplo n.º 2
0
            public PositioningToggleState Clone()
            {
                var cloned = new PositioningToggleState();

                cloned.Statements = Statements.Clone();
                cloned.Bullets    = Bullets.Clone();

                return(cloned);
            }