public void visit(TerminalD terminalD)
 {
     if (symbolType == SymbolType.Terminal)
     {
         if (terminalD.Name.Equals(name))
             found = true;
     }
 }
        public void visit(TerminalD terminalD)
        {
            // set current, ready for parent
            TerminalV terminalV = new TerminalV(terminalD, level + 1);

            terminalD.References.Add(terminalV);

            current = terminalV;
        }
        public void visit(TerminalD terminalD)
        {
            String value = terminalD.Name;

            Run run = new Run();
            if (terminalD.IsSelected)
                run.FontWeight = FontWeights.Bold;

            run.Text = terminalEncapsulation + value + terminalEncapsulation;

            representation.Inlines.Add(run);
        }
 private static Lexeme Reverse(TerminalD terminal)
 {
     return new Lexeme(LexemeType.Terminal, terminal.Name, -1);
 }
        /// <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(TerminalD terminalD)
 {
 }
        public GrammarNodeD Replace(GrammarNodeD itemToReplace, VADG.Global.SymbolType symbolType, string name)
        {
            OperationD parent = itemToReplace.Parent as OperationD;
            if (parent == null)
                throw new Exception("The item to replace does not have an operation D as a parent, fail.");

            // the rule we are editing
            NonterminalHeadD rule = itemToReplace.getMyRule();
            if (rule == null)
                throw new Exception("The item to replace could not find a nonterminalhead D associated with it.");

            // remove old item
            int index = parent.Children.IndexOf(itemToReplace);
            parent.Children.Remove(itemToReplace);
            itemToReplace.Dispose();

            // create new item to add
            GrammarNodeD newItem;
            if (symbolType == VADG.Global.SymbolType.Terminal)
            {
                // create new Terminal
                newItem = new TerminalD(name, parent);
            }
            else
            {
                // If the nont head doesn't exist, create and add to grammar
                NonterminalHeadD nontHead = model.DefinitiveGrammar.getNonterminal(name);

                if (nontHead == null)
                    nontHead = CreateNewNonterminal(name);

                newItem = nontHead.CreateNonterminalTailD(parent);
            }

            // insert new item into parent
            parent.insertChild(index, newItem);
            return newItem;
        }
 private void Init(TerminalD refIn, int levelIn)
 {
     reference = refIn;
     level = levelIn;
 }
 public TerminalV(TerminalD refIn, int levelIn)
 {
     Init(refIn, levelIn);
 }
        public void visit(TerminalD terminalD)
        {
            String value = terminalD.Name;

            representation += terminalEncapsulation + value + terminalEncapsulation;
        }
 public void visit(TerminalD terminalD)
 {
     terminalD.IsSelected = false;
 }