Ejemplo n.º 1
0
        public override void EnterTerminating_field(IddParser.Terminating_fieldContext context)
        {
            var alphaNumeric = context.field_id().ALPHA_OPTION() != null
                ? IdfFieldAlphaNumeric.Alpha
                : IdfFieldAlphaNumeric.Numeric;

            if (IsStartOfExtensibleField(context.field_properties()))
            {
                _inExtensibleSection  = true;
                _beginExtensibleIndex = _currentFieldIndex;
            }

            if (!_inExtensibleSection || _currentFieldIndex < _beginExtensibleIndex + currentObject.ExtensibleCountSize)
            {
                IdfField idfField = GetField(context.field_properties(), alphaNumeric);
                currentObject.Fields.Add(idfField);
            }
        }
Ejemplo n.º 2
0
        public IdfField GetField(IddParser.Field_propertiesContext context, IdfFieldAlphaNumeric alphaNumeric)
        {
            IdfField field = new IdfField();

            field.AlphaNumeric = alphaNumeric;

            IddParser.Field_propertiesContext propertyContext = context;
            IddParser.Field_propertyContext[] properties      = propertyContext.field_property();

            foreach (IddParser.Field_propertyContext prop in properties)
            {
                if (prop.AUTOSIZABLE_STATEMENT() != null)
                {
                    field.AutoSizeable = true;
                }
                else if (prop.AUTOCALCULATABLE_STATEMENT() != null)
                {
                    field.AutoCalculatable = true;
                }
                else if (prop.REQUIRED_FIELD_STATEMENT() != null)
                {
                    field.Required = true;
                }
                else if (prop.UNITS_STATEMENT() != null)
                {
                    field.Units = prop.UNITS_STATEMENT().GetText().Substring(7).Trim();
                }
                else if (prop.KEY_STATEMENT() != null)
                {
                    field.Keys.Add(prop.KEY_STATEMENT().GetText().Substring(5).Trim());
                }
                else if (prop.FIELD_STATEMENT() != null)
                {
                    field.Name = prop.FIELD_STATEMENT().GetText().Substring(7).Trim();
                }
                else if (prop.REFERENCE_STATEMENT() != null)
                {
                    field.ReferenceList.Add(prop.REFERENCE_STATEMENT().GetText().Substring(11).Trim());
                }
                else if (prop.REFERENCE_CLASS_NAME_STATEMENT() != null)
                {
                    field.ReferenceClassList.Add(prop.REFERENCE_CLASS_NAME_STATEMENT().GetText().Substring(22).Trim());
                }
                else if (prop.OBJECT_LIST_STATEMENT() != null)
                {
                    field.ObjectList.Add(prop.OBJECT_LIST_STATEMENT().GetText().Substring(13).Trim());
                }
                else if (prop.minimum_inclusive_statement() != null)
                {
                    field.MinType = IdfFieldMinMaxType.Inclusive;
                    field.Minimum = double.Parse(prop.minimum_inclusive_statement().minval.Text.Trim());
                }
                else if (prop.minimum_exclusive_statement() != null)
                {
                    field.MinType = IdfFieldMinMaxType.Exclusive;
                    field.Minimum = double.Parse(prop.minimum_exclusive_statement().minval.Text.Trim());
                }
                else if (prop.maximum_inclusive_statement() != null)
                {
                    field.MaxType = IdfFieldMinMaxType.Inclusive;
                    field.Maximum = double.Parse(prop.maximum_inclusive_statement().maxval.Text.Trim());
                }
                else if (prop.maximum_exclusive_statement() != null)
                {
                    field.MaxType = IdfFieldMinMaxType.Exclusive;
                    field.Maximum = double.Parse(prop.maximum_exclusive_statement().maxval.Text.Trim());
                }
                else if (prop.DEFAULT_STATEMENT() != null)
                {
                    field.Default = prop.DEFAULT_STATEMENT().GetText().Substring(9).Trim();
                }
            }

            return(field);
        }