Exemplo n.º 1
0
        private static Keyword CreateKeyword(string name)
        {
            var validName = TinyLispHelper.IsValidSymbolName(name, true);

            if (!validName)
            {
                throw new ArgumentException($"Invalid keyword name: '{name}'.", nameof(name));
            }

            var realName = GetRealName(name);
            var have     = Symbols.TryGetValue(realName, out var existing);

            if (have)
            {
                return((Keyword)existing);
            }

            var @new = new Keyword(realName);

            RegisterSymbol(@new);
            return(@new);
        }
Exemplo n.º 2
0
        private static Symbol CreateSymbol(string name)
        {
            var validName = TinyLispHelper.IsValidSymbolName(name, false);

            if (!validName)
            {
                throw new ArgumentException($"Invalid symbol name: '{name}'.", nameof(name));
            }

            var realName = GetRealName(name);
            var have     = Symbols.TryGetValue(realName, out var existing);

            if (have)
            {
                return(existing);
            }

            var @new = new Symbol(realName);

            RegisterSymbol(@new);
            return(@new);
        }