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; }
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(); }
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)); }
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)); }
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)); }
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)); }
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)); }