示例#1
0
        public bool CheckIfNameExist(Sar sar)
        {
            var scope = _currentScope;
            bool result = false;
            bool cont = true;
            do
            {
                var objs = from x in _symbolTable.Values
                           where x.Scope == scope && x.Value == sar.Value
                           select x;
                if (objs.Any())
                {
                    sar.SymObj = objs.First();
                    result = true;
                    cont = false;
                }
                if (scope != "g")
                {
                    scope = scope.Substring(0, scope.LastIndexOf('.'));
                }
                else
                {
                    cont = false;
                }

            } while (cont);
            return result;
        }
示例#2
0
 public bool CheckIfNameIsPartOfMember(Sar variable, string member)
 {
     string scope = "g." + member;
     var data = from x in _symbolTable.Values
         where x.Scope == scope && x.Value == variable.Value && x.Data.AccessMode == Parser.Public
         select x;
     variable.SymObj = data.FirstOrDefault();
     return data.Any();
 }
示例#3
0
 private void SemanticNotaMember(Sar member, Sar holder)
 {
     _errors.Add(string.Format("Semantic: On line: {0} {1} is not a member of {2}", _lex.LineCounter(), member.Value, holder.Value));
     throw new Exception(string.Format("Semantic: On line: {0} {1} is not a member of {2}", _lex.LineCounter(), member.Value, holder.Value));
 }
示例#4
0
 private void SemanticMultipleSameName(Sar member)
 {
     _errors.Add(string.Format("Semantic: On line: {0} {1} is a dulpicate definition", _lex.LineCounter(), member.Value));
     throw new Exception(string.Format("Semantic: On line: {0} {1} is a dulpicate definition", _lex.LineCounter(), member.Value));
 }
示例#5
0
 private void SemanticInvalidArgument(Sar member)
 {
     _errors.Add(string.Format("Semantic: On line: {0} {1} has invalid arguments", _lex.LineCounter(), member.Value));
     throw new Exception(string.Format("Semantic: On line: {0} {1} has invalid arguments", _lex.LineCounter(), member.Value));
 }
示例#6
0
 private void SemanticCantAssign(Sar sar, int line)
 {
     _errors.Add(string.Format("Semantic: On line: {0} {1} is unassignable", line, sar.Value));
     throw new Exception(string.Format("Semantic: On line: {0} {1} is unassignable", line, sar.Value));
 }
示例#7
0
 private void SemanticAssignType(Sar sar1, Sar sar2, int line)
 {
     _errors.Add(string.Format("Semantic: On line: {0} incompatible types. {1} type is {2} and {3} type is {4} ", line, sar1.Value, sar1.Type, sar2.Value, sar2.Type));
     throw new Exception(string.Format("Semantic: On line: {0} incompatible types. {1} type is {2} and {3} type is {4} ", line, sar1.Value, sar1.Type, sar2.Value, sar2.Type));
 }