/// <summary>
        /// Creates a visualised grammar based on the definitive grammar passed.
        /// </summary>
        /// <param name="dGrammarIn"></param>
        internal VisualisedGrammar(DefinitiveGrammar dGrammarIn)
        {
            // obsolete - using vistor pattern
            //startSymbol = dGrammarIn.StartSymbol.CreateVisualGrammar(true);

            // create visitor
            GrammarNodeDCreateVisualVisitor visitor = new GrammarNodeDCreateVisualVisitor();
            // traverse tree
            dGrammarIn.StartSymbol.accept(visitor);

            if (visitor.CurrentNodeV as NonterminalHeadV == null)
                throw new Exception("Creating the visualised grammar from the definitive failed.");

            startSymbol = (NonterminalHeadV)visitor.CurrentNodeV;
        }
 public void setDefinitiveGrammar(DefinitiveGrammar dg)
 {
     definitiveGrammar = dg;
     visualisedGrammar = null;
 }
 /// <summary>
 /// Will construct a definitive grammar from an input string, throw exception with compiler error otherwise.
 /// Assumes first rule is the start symbol.
 /// </summary>
 /// <param name="input"></param>
 public void setDefinitiveGrammar(String input)
 {
     bool noError = bnfParser.Parse(input);
     if (noError)
     {
         // no start symbol specified, assume first entry
         definitiveGrammar = new DefinitiveGrammar(bnfParser.Rules, bnfParser.Rules[0]);
         visualisedGrammar = null;
     }
     else
     {
         throw new Exception(bnfParser.ErrorText);
     }
 }
 public GrammarModel(DefinitiveGrammar definitiveGrammarIn)
 {
     bnfParser = new BNFParser();
     definitiveGrammar = definitiveGrammarIn;
 }