예제 #1
0
        private void OnSemanticsValidate(object sender, SemanticsValidateEventArgs e)
        {
            bool ignoreCase       = AP.IgnoreCase;
            AleExpressionParser P = sender as AleExpressionParser;

            // We want for some reasons that "Rnd" can't be a variable name
            if ((e.Term.HashCode == -1028829980 && !ignoreCase && e.Term.Value.ToString() == "Rnd") ||
                (e.Term.HashCode == 1843313028 && ignoreCase && e.Term.Value.ToString() == "RND"))
            {
                AleTerm parent = e.Term.Parent;
                if (e.Term.TypeOfTerm == AleTermType.Variable && (parent == null || parent.Operation == null || !parent.Operation.IsClassOperator || e.Term != parent[1]))
                {
                    P.SetError(e.Term.Token.StartInOrigin, AleExpressionParser.ERROR_INVALIDVARIABLE);
                }
            }
        }
예제 #2
0
        private void OnSemanticsValidate(object sender, SemanticsValidateEventArgs e)
        {
            bool ignoreCase = chkIgnoreCase.Checked;
            AleExpressionParser P = sender as AleExpressionParser;

            // We want for some reasons that "Rnd" can't be a operador name
            if ((e.Term.HashCode == -1028829980 && !ignoreCase && e.Term.Value.ToString() == "Rnd") ||
                (e.Term.HashCode == 1843313028 && ignoreCase && e.Term.Value.ToString() == "RND"))
            {
                AleTerm parent = e.Term.Parent;
                if (e.Term.TypeOfTerm == AleTermType.Variable && (parent == null || parent.Operation == null || !parent.Operation.IsClassOperator || e.Term != parent[1]))
                    P.SetError(e.Term.Token.StartInOrigin, AleExpressionParser.ERROR_INVALIDVARIABLE);
            }
        }