コード例 #1
0
ファイル: Interpreter.cs プロジェクト: HelgeL/DynamicExpresso
        /// <summary>
        /// Creates a new Interpreter using the specified options.
        /// </summary>
        /// <param name="options"></param>
        public Interpreter(InterpreterOptions options)
        {
            var caseInsensitive          = options.HasFlag(InterpreterOptions.CaseInsensitive);
            var allowSingleQuotedStrings = options.HasFlag(InterpreterOptions.AllowSingleQuotedStrings);

            _settings = new ParserSettings(caseInsensitive, allowSingleQuotedStrings);

            if ((options & InterpreterOptions.SystemKeywords) == InterpreterOptions.SystemKeywords)
            {
                SetIdentifiers(LanguageConstants.Literals);
            }

            if ((options & InterpreterOptions.PrimitiveTypes) == InterpreterOptions.PrimitiveTypes)
            {
                Reference(LanguageConstants.PrimitiveTypes);
                Reference(LanguageConstants.CSharpPrimitiveTypes);
            }

            if ((options & InterpreterOptions.CommonTypes) == InterpreterOptions.CommonTypes)
            {
                Reference(LanguageConstants.CommonTypes);
            }

            _visitors.Add(new DisableReflectionVisitor());
        }
コード例 #2
0
        /// <summary>
        /// Creates a new Interpreter using the specified options.
        /// </summary>
        /// <param name="options"></param>
        public Interpreter(InterpreterOptions options)
        {
            var caseInsensitive = options.HasFlag(InterpreterOptions.CaseInsensitive);

            var lateBindObject = options.HasFlag(InterpreterOptions.LateBindObject);

            _settings = new ParserSettings(caseInsensitive, lateBindObject);

            if ((options & InterpreterOptions.SystemKeywords) == InterpreterOptions.SystemKeywords)
            {
                SetIdentifiers(LanguageConstants.Literals);
            }

            if ((options & InterpreterOptions.PrimitiveTypes) == InterpreterOptions.PrimitiveTypes)
            {
                Reference(LanguageConstants.PrimitiveTypes);
                Reference(LanguageConstants.CSharpPrimitiveTypes);
            }

            if ((options & InterpreterOptions.CommonTypes) == InterpreterOptions.CommonTypes)
            {
                Reference(LanguageConstants.CommonTypes);
            }

            if ((options & InterpreterOptions.LambdaExpressions) == InterpreterOptions.LambdaExpressions)
            {
                _settings.LambdaExpressions = true;
            }

            _visitors.Add(new DisableReflectionVisitor());
        }
コード例 #3
0
        public Interpreter(InterpreterOptions options)
        {
            var caseInsensitive = options.HasFlag(InterpreterOptions.CaseInsensitive);

            _settings = new ParserSettings(caseInsensitive);

            if ((options & InterpreterOptions.SystemKeywords) == InterpreterOptions.SystemKeywords)
            {
                FillSystemKeywords();
            }

            if ((options & InterpreterOptions.PrimitiveTypes) == InterpreterOptions.PrimitiveTypes)
            {
                FillPrimitiveTypes();
            }

            if ((options & InterpreterOptions.CommonTypes) == InterpreterOptions.CommonTypes)
            {
                FillCommonTypes();
            }
        }
コード例 #4
0
        /// <summary>
        /// Create a new Interpreter using the specified options.
        /// </summary>
        /// <param name="options"></param>
        public Interpreter(InterpreterOptions options)
        {
            var caseInsensitive = options.HasFlag(InterpreterOptions.CaseInsensitive);

            _settings = new ParserSettings(caseInsensitive);

            if ((options & InterpreterOptions.SystemKeywords) == InterpreterOptions.SystemKeywords)
            {
                SetIdentifiers(LanguageConstants.Literals);
            }

            if ((options & InterpreterOptions.PrimitiveTypes) == InterpreterOptions.PrimitiveTypes)
            {
                Reference(LanguageConstants.PrimitiveTypes);
                Reference(LanguageConstants.CSharpPrimitiveTypes);
            }

            if ((options & InterpreterOptions.CommonTypes) == InterpreterOptions.CommonTypes)
            {
                Reference(LanguageConstants.CommonTypes);
            }
        }