Ejemplo n.º 1
0
        internal bool ParseTrigger(Lines lines)
        {
            Match match;

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

            lines.LastLineTryMatch(Patterns.BlankLine);

            var triggerName    = match.Groups [1].Value;
            var firstStatement = match.Groups [3].Value;

            Listener.OnBeginTrigger(triggerName);

            lines.Unindent(triggerName.Length + 1);

            if (firstStatement == "VAR")
            {
                ParseLocals(lines);
            }

            ParseCodeLines(lines);

            Listener.OnEndTrigger();

            return(true);
        }
        internal void ParseObject(Lines lines)
        {
            var match      = lines.FirstLineMustMatch(Patterns.ObjectSignature);
            var objectType = match.Groups [1].Value.ToEnum <ObjectType>();
            var objectID   = match.Groups [2].Value.ToInteger();
            var objectName = match.Groups [3].Value;

            Listener.OnBeginObject(objectType, objectID, objectName);

            lines.FirstLineMustMatch(Patterns.BeginObject);
            while (lines.LastLineTryMatch(Patterns.BlankLine))
            {
                ;
            }
            lines.LastLineMustMatch(Patterns.EndObject);

            // Because of the odd indentation of RDLData, we need to extract it
            // first (if present), so that the remaining lines follow the normal
            // section pattern.
            if (objectType == ObjectType.Report)
            {
                ParseRdlDataSection(lines);
            }

            lines.Unindent(2);

            foreach (var chunk in lines.Chunks(Patterns.SectionSignature))
            {
                ParseSection(chunk, objectType);
            }

            Listener.OnEndObject();
        }
Ejemplo n.º 3
0
        internal void ParseProperty(Lines lines, bool mayHaveTriggers)
        {
            if (mayHaveTriggers)
            {
                if (ParseTrigger(lines))
                {
                    return;
                }
            }

            var match        = lines.FirstLineMustMatch(Patterns.PropertySignature);
            var propertyName = match.Groups[1].Value;
            //propertyName = CodeStyle.CustomPropertyMappings.GetRealName(propertyName);
            var propertyValueFirstLine = match.Groups[3].Value;

            switch (propertyName)
            {
            case "ActionList":
                lines.FirstLineMustMatch(Patterns.BeginSection);
                lines.LastLineMustMatch(Patterns.EndSection);
                lines.Unindent(2);
                ParseActionList(lines);
                return;

            case "Menu":
                lines.FirstLineMustMatch(Patterns.BeginSection);
                lines.LastLineMustMatch(Patterns.EndSection);
                lines.Unindent(2);
                ParseFormMenuItems(lines);
                return;
            }

            var stringBuilder = new StringBuilder(propertyValueFirstLine);

            if (IsMultiLineProperty(propertyName))
            {
                foreach (var line in lines)
                {
                    stringBuilder.AppendFormat(" {0}", line.TrimStart());
                }
            }
            var propertyValue = stringBuilder.ToString().TrimEnd(";".ToCharArray());

            Listener.OnProperty(propertyName, propertyValue);
        }
Ejemplo n.º 4
0
        internal void ParseFormMenuItem(Lines lines)
        {
            var match = lines.FirstLineMustMatch(Patterns.BeginMenuItem);

            Listener.OnBeginFormMenuItem();

            lines.Unindent(2);
            lines.FirstLineTryMatch(Patterns.BlankLine);
            FormMenuItemProperties(lines);

            Listener.OnEndFormMenuItem();
        }
        internal void ParseCodeLines(Lines lines)
        {
            lines.LastLineTryMatch(Patterns.BlankLine);
            lines.FirstLineTryMatch(Patterns.BeginCodeBlock);
            lines.LastLineMustMatch(Patterns.EndCodeBlock);

            lines.Unindent(2);

            foreach (var line in lines)
            {
                Listener.OnCodeLine(line);
            }
        }
Ejemplo n.º 6
0
        internal void ParseProperty(Lines lines, bool mayHaveTriggers)
        {
            if (mayHaveTriggers)
            {
                if (ParseTrigger(lines))
                {
                    return;
                }
            }

            var match                  = lines.FirstLineMustMatch(Patterns.PropertySignature);
            var propertyName           = match.Groups[1].Value;
            var propertyValueFirstLine = match.Groups[2].Value;

            if (propertyName == "ActionList")
            {
                lines.FirstLineMustMatch(Patterns.BeginSection);
                lines.LastLineMustMatch(Patterns.EndSection);
                lines.Unindent(2);
                ParseActionList(lines);
                return;
            }

            var stringBuilder = new StringBuilder(propertyValueFirstLine);

            lines.Unindent(propertyName.Length + 1);

            foreach (var line in lines)
            {
                stringBuilder.AppendFormat(" {0}", line.TrimStart());
                // stringBuilder.Append(line.TrimStart());
            }

            var propertyValue = stringBuilder.ToString().TrimEnd(";".ToCharArray());

            Listener.OnProperty(propertyName, propertyValue);
        }
        internal void ParseFormMenuItem(Lines lines)
        {
            var match             = lines.FirstLineMustMatch(Patterns.PageAction);
            var menuItemSeparator = match.Groups[1].Value;

            Listener.OnBeginFormMenuItem();

            if (menuItemSeparator == ";")
            {
                lines.Unindent(2);
                FormMenuItemProperties(lines);
            }

            Listener.OnEndFormMenuItem();
        }
        internal void ParseReportDataItem(Lines lines, ObjectType objectType)
        {
            lines.FirstLineMustMatch(Patterns.BeginClassicSection);
            lines.LastLineMustMatch(Patterns.EndDataItem);
            lines.Unindent(2);

            Listener.OnBeginReportDataItem();

            foreach (var chunk in lines.Chunks(Patterns.SectionSignature))
            {
                ParseSection(chunk, objectType);
            }

            Listener.OnEndReportDataItem();
        }
        internal void ParseTableKey(Lines lines)
        {
            var match      = lines.FirstLineMustMatch(Patterns.TableKey);
            var keyEnabled = match.Groups[1].Value.ToNullableBoolean(CodeStyle.Localization);
            var keyFields  = match.Groups[2].Value.TrimEnd().Split(",".ToCharArray());
            var separator  = match.Groups[3].Value;

            Listener.OnBeginTableKey(keyEnabled, keyFields);

            if (separator == ";")
            {
                lines.Unindent(Math.Min(match.Length, 47));
                ParseTableKeyProperties(lines);
            }

            Listener.OnEndTableKey();
        }
Ejemplo n.º 10
0
        internal void ParseDocumentation(Lines lines)
        {
            lines.FirstLineMustMatch(Patterns.BeginDocumentation);
            lines.LastLineMustMatch(Patterns.EndDocumentation);

            if (lines.FirstLineTryMatch(Patterns.BeginSection))
            {
                lines.LastLineMustMatch(Patterns.EndSection);
            }

            lines.Unindent(2);

            while (lines.Any())
            {
                Listener.OnCodeLine(lines.FirstLineMustMatch(Patterns.Any).Value);
            }
        }
Ejemplo n.º 11
0
        internal void ParseReportLabel(Lines lines)
        {
            var match          = lines.FirstLineMustMatch(Patterns.ReportLabel);
            var labelID        = match.Groups[1].Value.ToInteger();
            var labelName      = match.Groups[2].Value.Trim();
            var labelSeparator = match.Groups[3].Value;

            Listener.OnBeginReportLabel(labelID, labelName);

            if (labelSeparator == ";")
            {
                lines.Unindent(28);
                ParseReportLabelProperties(lines);
            }

            Listener.OnEndReportLabel();
        }
Ejemplo n.º 12
0
        internal void ParseFormControl(Lines lines)
        {
            var match            = lines.FirstLineMustMatch(Patterns.FormControl);
            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 = FindBestIndentationForFormControl(match.Value, lines);
                lines.Unindent(indentation);
                var list   = lines.ToList();
                int dedent = 0;
                foreach (var line in lines.Skip(1))
                {
                    var trimmedLine = line.TrimStart();
                    if (trimmedLine.EndsWith("=BEGIN") || trimmedLine.EndsWith("=VAR") || trimmedLine.EndsWith("=MENUITEMS") || trimmedLine.Contains("RunFormLink="))
                    {
                        dedent = line.Length - trimmedLine.Length;
                        break;
                    }

                    if (dedent == 0)
                    {
                        dedent = line.Length - trimmedLine.Length;
                    }
                    int diff = line.Length - trimmedLine.Length;
                    if ((diff > 0) && (diff < dedent))
                    {
                        dedent = diff;
                    }
                }
                lines = new Lines(list);
                lines.Unindent(dedent);
                ParseFormControlProperties(lines);
            }

            Listener.OnEndFormControl();
        }
Ejemplo n.º 13
0
        internal void ParseFieldGroup(Lines lines)
        {
            var match            = lines.FirstLineMustMatch(Patterns.FieldGroup);
            var fieldGroupID     = match.Groups[1].Value.Trim().ToInteger();
            var fieldGroupName   = match.Groups[2].Value.TrimEnd();
            var fieldGroupFields = match.Groups[3].Value.TrimEnd().Split(",".ToCharArray());
            var separator        = match.Groups[4].Value;

            Listener.OnBeginTableFieldGroup(fieldGroupID, fieldGroupName, fieldGroupFields);

            if (separator == ";")
            {
                lines.Unindent(Math.Min(match.Length, 69));
                ParseFieldGroupProperties(lines);
            }

            Listener.OnEndTableFieldGroup();
        }
        internal void ParseDataPortField(Lines lines)
        {
            var match      = lines.FirstLineMustMatch(Patterns.DataportField);
            var startPos   = match.Groups [1].Value.ToNullableInteger();
            var width      = match.Groups[2].Value.ToNullableInteger();
            var sourceExpr = match.Groups [3].Value.TrimEnd();
            var separator  = match.Groups [4].Value;

            Listener.OnBeginDataPortField(startPos, width, sourceExpr);

            if (separator == ";")
            {
                lines.Unindent(Math.Min(match.Length, 35));
                ParseDataPortFieldProperties(lines);
            }

            Listener.OnEndDataPortField();
        }
        internal void ParsePageAction(Lines lines)
        {
            var match             = lines.FirstLineMustMatch(Patterns.PageAction);
            var actionID          = match.Groups [1].Value.ToInteger();
            var actionIndentation = match.Groups [2].Value.ToNullableInteger();
            var actionType        = match.Groups [3].Value.ToEnum <PageActionType>();
            var actionSeparator   = match.Groups [4].Value;

            Listener.OnBeginPageAction(actionID, actionIndentation, actionType);

            if (actionSeparator == ";")
            {
                lines.Unindent(16);
                ParsePageActionProperties(lines);
            }

            Listener.OnEndPageAction();
        }
        internal void ParseReportElement(Lines lines)
        {
            var match              = lines.FirstLineMustMatch(Patterns.ReportElement);
            var elementID          = match.Groups[1].Value.ToInteger();
            var elementIndentation = match.Groups[2].Value.ToNullableInteger();
            var elementType        = match.Groups[3].Value.ToEnum <ReportElementType>();
            var elementName        = match.Groups[4].Value.Trim();
            var elementSeparator   = match.Groups[5].Value;

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

            if (elementSeparator == ";")
            {
                lines.Unindent(11);
                ParseReportElementProperties(lines);
            }

            Listener.OnEndReportElement();
        }
        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();
        }
Ejemplo n.º 18
0
        internal void ParseTableField(Lines lines)
        {
            var match        = lines.FirstLineMustMatch(Patterns.TableField);
            var fieldNo      = match.Groups [1].Value.ToInteger();
            var fieldEnabled = match.Groups [2].Value.ToNullableBoolean();
            var fieldName    = match.Groups [3].Value.TrimEnd();
            var fieldType    = match.Groups [4].Value.TrimEnd();
            var fieldLength  = ParseFieldLength(ref fieldType);
            var separator    = match.Groups [5].Value;

            Listener.OnBeginTableField(fieldNo, fieldEnabled, fieldName, fieldType.ToEnum <TableFieldType>(), fieldLength);

            if (separator == ";")
            {
                lines.Unindent(Math.Min(match.Length, 47));
                ParseTableFieldProperties(lines);
            }

            Listener.OnEndTableField();
        }
Ejemplo n.º 19
0
        internal void ParseXmlPortElement(Lines lines)
        {
            var match              = lines.FirstLineMustMatch(Patterns.XmlPortElement);
            var elementID          = match.Groups[1].Value.ToGuid();
            var elementIndentation = match.Groups[2].Value.ToNullableInteger();
            var elementName        = match.Groups[3].Value;
            var elementNodeType    = match.Groups[4].Value.ToEnum <XmlPortNodeType>();
            var elementSourceType  = match.Groups[5].Value.ToEnum <XmlPortSourceType>();
            var elementSeparator   = match.Groups[6].Value;

            Listener.OnBeginXmlPortElement(elementID, elementIndentation, elementName, elementNodeType, elementSourceType);

            if (elementSeparator == ";")
            {
                lines.Unindent(Math.Min(match.Length, 46));
                ParseXmlPortElementProperties(lines);
            }

            Listener.OnEndXmlPortElement();
        }
Ejemplo n.º 20
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 ParseMenuSuiteNode(Lines lines)
        {
            var match         = lines.FirstLineMustMatch(Patterns.MenuSuiteNode);
            var nodeType      = match.Groups[1].Value.ToMenuSuiteNodeType();
            var nodeID        = match.Groups[2].Value.ToGuid();
            var nodeSeparator = match.Groups[3].Value;

            Listener.OnBeginMenuSuiteNode(nodeType, nodeID);

            if (nodeSeparator == ";")
            {
                lines.Unindent(60);
                lines.LastLineMustMatch(Patterns.EndMenuSuiteNode);

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

            Listener.OnEndMenuSuiteNode();
        }
        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();
        }
Ejemplo n.º 23
0
        internal void ParseSection(Lines lines, ObjectType objectType, bool forceNewFormat = false, bool inRequestFormOrPage = false)
        {
            var match       = lines.FirstLineMustMatch(Patterns.SectionSignature);
            var sectionType = match.Groups[1].Value.ToSectionType();

            Listener.OnBeginSection(sectionType);

            lines.FirstLineMustMatch(Patterns.BeginSection);
            lines.LastLineMustMatch(Patterns.EndSection);
            lines.Unindent(2);

            switch (sectionType)
            {
            case SectionType.ObjectProperties:
                ParseObjectPropertiesSection(lines);
                break;

            case SectionType.Properties:
                ParsePropertiesSection(lines);
                break;

            case SectionType.Fields:
                switch (objectType)
                {
                case ObjectType.Table:
                    ParseTableFieldsSection(lines);
                    break;

                case ObjectType.Dataport:
                    ParseDataPortFieldsSection(lines);
                    break;
                }
                break;

            case SectionType.Keys:
                ParseKeysSection(lines);
                break;

            case SectionType.FieldGroups:
                ParseFieldGroupsSection(lines);
                break;

            case SectionType.Controls:
                switch (objectType)
                {
                case ObjectType.Page:
                case ObjectType.XmlPort:
                    ParsePageControlsSection(lines);
                    break;

                case ObjectType.Form:
                case ObjectType.Dataport:
                    ParseFormControlsSection(lines);
                    break;

                case ObjectType.Report:
                    if (forceNewFormat)
                    {
                        ParsePageControlsSection(lines);
                    }
                    else
                    {
                        if (inRequestFormOrPage)
                        {
                            ParseFormControlsSection(lines);
                        }
                        else
                        {
                            ParseReportControlsSection(lines);
                        }
                    }
                    break;
                }
                break;


            case SectionType.Elements:
                switch (objectType)
                {
                case ObjectType.Query:
                    ParseQueryElementsSection(lines);
                    break;

                case ObjectType.XmlPort:
                    ParseXmlPortElementsSection(lines);
                    break;
                }
                break;

            case SectionType.Events:
                break;

            case SectionType.Dataset:
                ParseDatasetSection(lines);
                break;

            case SectionType.Labels:
                ParseLabelsSection(lines);
                break;

            case SectionType.RdlData:
                break;

            case SectionType.WordLayout:
                ParseWordLayoutSection(lines);
                break;

            case SectionType.Code:
                ParseCodeSection(lines);
                break;

            case SectionType.RequestPage:
                ParseRequestPageSection(lines, objectType);
                break;

            case SectionType.MenuNodes:
                ParseMenuNodesSection(lines);
                break;

            case SectionType.RequestForm:
                ParseRequestFormSection(lines, objectType);
                break;

            case SectionType.DataItems:
                ParseDataItemsSection(lines, objectType);
                break;

            case SectionType.Sections:
                ParseSectionsSection(lines, objectType);
                break;

            default:
                Exceptions.ThrowException(Exceptions.UnknownSectionType, sectionType);
                break;
            }

            Listener.OnEndSection();
        }