예제 #1
0
파일: Lexer.cs 프로젝트: paralect/Schematra
        /// <summary>
        /// Parsing of schema-def-body nonterm
        /// </summary>
        private void ParseSchemaDefBody(ParseTreeNode node, RecordDefinition schemadef)
        {
            _currentNode = node;

            foreach (var child in node.ChildNodes)
            {
                switch (child.Term.Name)
                {
                    case SchematraGrammer.term_field:
                        var fieldDefinition = new FieldDefinition();
                        ParseField(child, fieldDefinition);
                        schemadef.FieldDefinitions.Add(fieldDefinition);
                        break;
                }
            }
        }
예제 #2
0
파일: Lexer.cs 프로젝트: paralect/Schematra
        /// <summary>
        /// Parsing of field nonterm
        /// </summary>
        private void ParseField(ParseTreeNode node, FieldDefinition fieldDefinition)
        {
            _currentNode = node;

            foreach (var child in node.ChildNodes)
            {
                if (child.Term == null || child.Term.Name == null)
                    continue;

                switch (child.Term.Name)
                {
                    case SchematraGrammer.term_field_index:
                        fieldDefinition.Index = Int32.Parse(child.Token.Value.ToString());
                        break;

                    case SchematraGrammer.term_field_qualifier:
                        fieldDefinition.SetQualifierByString(child.ChildNodes[0].Term.Name);
                        break;

                    case SchematraGrammer.term_field_nullable:
                        fieldDefinition.Nullable = child.ChildNodes.Count > 0;
                        break;

                    case SchematraGrammer.term_field_schema:
                        fieldDefinition.TypeName = child.Token.Value.ToString();
                        break;

                    case SchematraGrammer.term_field_name:
                        fieldDefinition.Name = child.Token.Value.ToString();
                        break;

                    case SchematraGrammer.term_field_init_value:
                        break;
                }
            }
        }