Exemple #1
0
        public LexemVariable(string name, LexemValue value = null)
            : this()
        {
            if (String.IsNullOrEmpty(name))
                throw new ArgumentException("Variable Name can't be null or empty");

            this.Name = name;

            if (!CheckVariableName(this.Name))
                throw new FormatException(String.Format($"Variable Name {this.Name} is incorrect"));

            this.Value = value;
        }
Exemple #2
0
        public LexemVariable Set(string name, LexemValue value)
        {
            if (value == null || String.IsNullOrEmpty(name))
                return null;

            var variable = this.Get(name);

            if (variable == null)
                return this.Add(name, value);

            variable.Value = value;

            return variable;
        }
Exemple #3
0
        public virtual LexemVariable Execute(LexemValue argument, Lexem lexem)
        {
            if (this.OnLexemExecution != null)
                return this.OnLexemExecution(argument, lexem);

            return null;
        }
Exemple #4
0
        public LexemVariable Add(string name, LexemValue value)
        {
            var variable = new LexemVariable(name, value);

            _variables.Add(variable);

            return variable;
        }