public void visit(NonterminalTailD nonterminalTailD)
        {
            NonterminalTailV nonterminalTailV = new NonterminalTailV(nonterminalTailD, level + 1);

            nonterminalTailD.AddReference(nonterminalTailV);

            current = nonterminalTailV;
        }
 private static Lexeme Reverse(NonterminalTailD nont)
 {
     return new Lexeme(LexemeType.Nonterminal, nont.Reference.Name, -1);
 }
 public void visit(NonterminalTailD nonterminalTailD)
 {
     if (!found && !rulesVisited.Contains(nonterminalTailD.Reference))
         // visit the rule :)
         visit(nonterminalTailD.Reference);
 }
 public NonterminalTailV(NonterminalTailD refIn, int levelIn)
 {
     Init(refIn, levelIn);
 }
 private void Init(NonterminalTailD refIn, int levelIn)
 {
     reference = refIn;
     level = levelIn;
 }
        /// <summary>
        /// Returns the rule structure, without the ChoiceLineD
        /// </summary>
        /// <param name="productionRuleLexemes"></param>
        /// <returns></returns>
        private void CreateRuleDataStructure(List<Lexeme> productionRuleLexemes, ChoiceLineD choiceLineD)
        {
            //GrammarNodeD returnVal;
            OperationD current = choiceLineD; // points to which level we are at
            //returnVal = current;

            // Split by Choice as this has the highest precedence
            List<Lexeme> choiceLexemes = new List<Lexeme>();
            ArrayList choices = new ArrayList();

            foreach (Lexeme lexeme in productionRuleLexemes)
            {
                if (lexeme.Type == LexemeType.Choice)
                {
                    choices.Add(choiceLexemes);
                    choiceLexemes = new List<Lexeme>();
                }
                else
                {
                    choiceLexemes.Add(lexeme);
                }
            }

            // add last choice list
            choices.Add(choiceLexemes);

            // put in a choiceD
            ChoiceD choiceD = new ChoiceD(current);
            current.appendChild(choiceD);
            current = choiceD; // move down a level

            // add the concatenated items for each Choice
            foreach (List<Lexeme> concatLexemes in choices)
            {
                ConcatenationD concatenation = new ConcatenationD(current);

                foreach (Lexeme lexeme in concatLexemes)
                {
                    if (lexeme.Type == LexemeType.Nonterminal)
                    {
                        // create nonterminal tail from the nonterminalhead
                        NonterminalHeadD nontHead = getNonterminalHead(lexeme.Value);
                        if (nontHead == null)
                            throw new Exception("Could not find a defined rule for the Nonterminal: " + lexeme.Value);

                        NonterminalTailD nontTail = new NonterminalTailD(nontHead, concatenation);

                        // add the tail to current children
                        concatenation.appendChild(nontTail);
                    }
                    else if (lexeme.Type == LexemeType.Terminal)
                    {
                        TerminalD terminalD = new TerminalD(lexeme.Value, concatenation);
                        concatenation.appendChild(terminalD);
                    }
                    else if (lexeme.Type == LexemeType.Undefined)
                    {
                        UndefinedD undefinedD = new UndefinedD(concatenation);
                        concatenation.appendChild(undefinedD);
                    }
                    else if (lexeme.Type != LexemeType.Concatenation)
                    {
                        // Lexes should only be of type Nont, T and Concat. Error
                        throw new Exception("Lexeme was not of type Nonterminal, Terminal or Concatenation");
                    }
                }

                current.appendChild(concatenation);
            }
        }
 public void visit(NonterminalTailD nonterminalTailD)
 {
 }
 public void visit(NonterminalTailD nonterminalTailD)
 {
     representation.Inlines.Add(new Run(nonterminalTailD.Reference.Name));
 }
 public void visit(NonterminalTailD nonterminalTailD)
 {
     representation += nonterminalTailD.Reference.Name;
 }
 public void visit(NonterminalTailD nonterminalTailD)
 {
     nonterminalTailD.IsSelected = false;
 }