Example #1
0
        /// <summary>
        /// Finds referred symbol in grammar and tokenizer
        /// </summary>
        /// <param name="grammar"></param>
        /// <param name="lexer"></param>
        public void CreateReference(Productions grammar, Lexer lexer)
        {
            object referredTo;

            if ((referredTo = grammar.GetRule(Symbol)) != null)
            {
                RefersTo = new RuleReference((Rule)referredTo, this);
            }
            else if ((referredTo = lexer.FindTokenType(Symbol)) != null)
            {
                RefersTo = new TokenReference((TokenType)referredTo, this);
            }

            if (RefersTo == null)
            {
                throw Exceptions.UnresolvedReferenceException(this);
            }
        }