Example #1
0
 public PdlDefinitionConcatenation(PdlBlock block, PdlDefinition definition)
     : base(block)
 {
     Assert.IsNotNull(definition, nameof(definition));
     Definition = definition;
     _hashCode  = ComputeHashCode();
 }
Example #2
0
        private PdlDefinition VisitDefinitionNode(IInternalTreeNode node)
        {
            PdlBlock      block      = null;
            PdlDefinition definition = null;

            for (int c = 0; c < node.Children.Count; c++)
            {
                var child = node.Children[c];
                switch (child.NodeType)
                {
                case TreeNodeType.Internal:
                    var internalNode = child as IInternalTreeNode;
                    var symbolValue  = internalNode.Symbol.Value;

                    if (PdlGrammar.Block == symbolValue)
                    {
                        block = VisitBlockNode(internalNode);
                    }
                    else if (PdlGrammar.Definition == symbolValue)
                    {
                        definition = VisitDefinitionNode(internalNode);
                    }
                    break;
                }
            }

            if (definition != null)
            {
                return(new PdlDefinitionConcatenation(block, definition));
            }

            return(new PdlDefinition(block));
        }
        public IGrammar Generate(PdlDefinition ebnf)
        {
            var grammarModel = new GrammarModel();

            Definition(ebnf, grammarModel);
            return(grammarModel.ToGrammar());
        }
Example #4
0
 public override void Visit(IInternalTreeNode node)
 {
     if (PdlGrammar.Definition == node.Symbol.Value)
     {
         Definition = VisitDefinitionNode(node);
     }
 }
        private void Definition(PdlDefinition definition, GrammarModel grammarModel)
        {
            Block(definition.Block, grammarModel);

            if (definition.NodeType != PdlNodeType.PdlDefinitionConcatenation)
            {
                return;
            }

            var definitionConcatenation = definition as PdlDefinitionConcatenation;

            Definition(definitionConcatenation.Definition, grammarModel);
        }