Example #1
0
        public static NonTerminal Create(Grammar aGrammar, IPhrase aParent, string aText)
        {
            //for terminal we don't return existing object, because it may be modified (terminal)
            bool lAllreadyExists = aGrammar.AllNonTerminals.ContainsKey(aText);
            NonTerminalCommon common;

            if (lAllreadyExists)
            {
                common = aGrammar.AllNonTerminals[aText];
            }
            else
            {
                common = new NonTerminalCommon(aGrammar, aText);
                aGrammar.AllNonTerminals.Add(aText, common);
            }
            NonTerminal lSym = new NonTerminal(common, aParent);

            lSym.OccurenceId = common.AllOccurences.Count;
            common.AllOccurences.Add(lSym);
            return(lSym);
        }
Example #2
0
 public NonTerminal(NonTerminal aSymbol)
 {
     mCommon = aSymbol.mCommon;
     mParent = aSymbol.Parent;
 }