internal bool ParseMultiLineTextConstant(Lines lines)
        {
            Match match = null;

            if (!lines.FirstLineTryMatch(Patterns.MultiLineTextConst, out match))
            {
                return(false);
            }

            var variableName  = match.Groups[1].Value;
            var variableID    = match.Groups[2].Value.ToInteger();
            var stringBuilder = new StringBuilder();

            while (lines.FirstLineTryMatch(Patterns.MultiLineTextConstValue, out match))
            {
                var languageCode  = match.Groups[1].Value;
                var languageValue = match.Groups[2].Value;
                var separator     = match.Groups[3].Value;
                if (String.IsNullOrEmpty(separator)) //TextConst value is multiline
                {
                    while (!lines.FirstLineTryMatch(Patterns.EndMultiLineTextConstValue, true))
                    {
                        var valuePart = lines.First();
                        lines.Consume(0, 0, valuePart.Length);
                        languageValue += valuePart + "\n";
                    }
                }
                stringBuilder.AppendFormat("{0}={1};", languageCode, languageValue);
            }

            Listener.OnVariable(variableID, variableName, VariableType.TextConst, "", null, null, stringBuilder.ToString(), false, null, false, false, null, false, false);

            return(true);
        }
        internal void ParsePageControl(Lines lines)
        {
            var match              = lines.FirstLineMustMatch(Patterns.PageControl);
            var controlID          = match.Groups[1].Value.ToInteger();
            var controlIndentation = match.Groups[2].Value.ToNullableInteger();
            var controlType        = match.Groups[3].Value.ToEnum <PageControlType>();
            var controlSeparator   = match.Groups[4].Value;

            Listener.OnBeginPageControl(controlID, controlIndentation, controlType);

            if (controlSeparator == ";")
            {
                var indentation = lines.First().Length - lines.First().TrimStart().Length;
                lines.Unindent(indentation);
                ParsePageControlProperties(lines);
            }

            Listener.OnEndPageControl();
        }
Exemplo n.º 3
0
        internal void ParseQueryElement(Lines lines)
        {
            var match               = lines.FirstLineMustMatch(Patterns.QueryElement);
            var elementID           = match.Groups[1].Value.ToInteger();
            var elementIndentation  = match.Groups[2].Value.ToNullableInteger();
            var elementType         = match.Groups[3].Value.ToEnum <QueryElementType>();
            var elementName         = match.Groups[4].Value.Trim();
            var propertyIndentation = (lines.First().Length - lines.First().TrimStart().Length);

            Listener.OnBeginQueryElement(elementID, elementIndentation, elementName, elementType);

            lines.Unindent(propertyIndentation);
            lines.LastLineMustMatch(Patterns.BlankLine);
            lines.LastLineMustMatch(Patterns.EndQueryElement);

            foreach (var chunk in lines.Chunks(Patterns.PropertySignature))
            {
                ParseProperty(chunk, true);
            }

            Listener.OnEndQueryElement();
        }
        internal void ParseFormControl(Lines lines)
        {
            var match            = lines.FirstLineMustMatch(Patterns.PageControl);
            var controlID        = match.Groups[1].Value.ToInteger();
            var controlType      = match.Groups[2].Value.ToEnum <ClassicControlType>();
            var posX             = match.Groups[3].Value.ToInteger();
            var posY             = match.Groups[4].Value.ToInteger();
            var width            = match.Groups[5].Value.ToInteger();
            var height           = match.Groups[6].Value.ToInteger();
            var controlSeparator = match.Groups[7].Value;

            Listener.OnBeginFormControl(controlID, controlType, posX, posY, width, height);

            if (controlSeparator == ";")
            {
                var indentation = lines.First().Length - lines.First().TrimStart().Length;
                lines.Unindent(indentation);
                ParseFormControlProperties(lines);
            }

            Listener.OnEndFormControl();
        }
Exemplo n.º 5
0
        private int FindBestIndentationForFormControl(string matchOfFirstLine, Lines lines)
        {
            int result      = matchOfFirstLine.Length;
            var firstLine   = lines.First();
            int firstIndent = firstLine.Length - firstLine.TrimStart().Length;

            if (firstIndent < result)
            {
                result = firstIndent;
            }
            if (lines.Count() > 1)
            {
                var secondLine   = lines.Skip(1).First();
                int secondIndent = secondLine.Length - secondLine.TrimStart().Length;
                if (secondIndent < result)
                {
                    result = secondIndent;
                }
            }
            return(result);
        }
        internal bool ParseVariable(Lines lines)
        {
            var   variablePattern = CodeStyle.NoVariableIds ? Patterns.VariableNoId : Patterns.Variable;
            Match match           = null;

            lines.FirstLineTryMatch(Patterns.BlankLine);
            if (!lines.FirstLineTryMatch(Patterns.MultiLineTextConst, out match))
            {
                if (!lines.FirstLineTryMatch(variablePattern, out match))
                {
                    return(false);
                }
            }

            var variableName = match.Groups[1].Value.TrimEnd();
            var variableID   = match.Groups[2].Value.ToInteger();
            var variableType = match.Groups[3].Value;

            if (String.IsNullOrEmpty(variableType))
            {
                variableType = "TextConst";
            }
            var variableSuppressDispose   = ParseSuppressDispose(ref variableType);
            var variableRunOnClient       = ParseRunOnClient(ref variableType);
            var variableWithEvents        = ParseWithEvents(ref variableType);
            var variableSecurityFiltering = ParseSecurityFiltering(ref variableType);
            var variableInDataSet         = ParseInDataSet(ref variableType);
            var variableDimensions        = ParseDimensions(ref variableType);
            var variableTemporary         = ParseTemporary(ref variableType);
            var variableConstValue        = ParseTextConstant(ref variableType); //.ToConstValue();
            var variableSubType           = ParseVariableSubType(ref variableType);
            var variableLength            = ParseVariableLength(ref variableType);
            var variableOptionString      = ParseOptionString(ref variableType);

            if (variableType == "TextConst")
            {
                var stringBuilder = new StringBuilder();
                while (lines.FirstLineTryMatch(Patterns.MultiLineTextConstValue, out match))
                {
                    var languageCode  = match.Groups[1].Value;
                    var languageValue = match.Groups[2].Value;
                    var separator     = match.Groups[3].Value;
                    if (String.IsNullOrEmpty(separator)) //TextConst value is multiline
                    {
                        while (!lines.FirstLineTryMatch(Patterns.EndMultiLineTextConstValue, true))
                        {
                            var valuePart = lines.First();
                            lines.Consume(0, 0, valuePart.Length);
                            languageValue += valuePart + "\n";
                        }
                    }
                    stringBuilder.AppendFormat("{0}={1};", languageCode, languageValue);
                }
                variableConstValue = stringBuilder.ToString();
                if (String.IsNullOrEmpty(variableConstValue))
                {
                    lines.FirstLineTryMatch(Patterns.EndOfCodeLine, true);
                }
            }

            Listener.OnVariable(
                variableID,
                variableName,
                variableType.ToEnum <VariableType>(),
                variableSubType,
                variableLength,
                variableOptionString,
                variableConstValue,
                variableTemporary,
                variableDimensions,
                variableRunOnClient,
                variableWithEvents,
                variableSecurityFiltering,
                variableInDataSet,
                variableSuppressDispose);

            return(true);
        }