This commit is contained in:
miks1965 2018-09-12 07:11:26 +03:00
parent d0ca82252b
commit 42b7d7263f
8 changed files with 52 additions and 10 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "4";
public const string Build = "2";
public const string Revision = "1786";
public const string Revision = "1787";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=4
%REVISION%=1786
%COREVERSION%=2
%REVISION%=1787
%MINOR%=4
%MAJOR%=3

View file

@ -152,8 +152,30 @@ namespace PascalABCCompiler.Errors
source_context = _source_context;
if (source_context != null && source_context.FileName != null)
base.fileName = source_context.FileName;
if (source_context == null && _bad_node != null) // искать source_context у Parentов
{
var bn = _bad_node;
do
{
bn = bn.Parent;
if (bn != null && bn.source_context != null)
{
source_context = bn.source_context;
if (source_context.FileName != null)
base.fileName = source_context.FileName;
break;
}
} while (bn != null);
}
bad_node = _bad_node;
}
public SyntaxError(string Message, string fileName, PascalABCCompiler.SyntaxTree.syntax_tree_node bad_node)
: this(Message, fileName, bad_node.source_context, bad_node) { }
public SyntaxError(string Message, PascalABCCompiler.SyntaxTree.syntax_tree_node bad_node)
: this(Message, null, bad_node.source_context, bad_node) { }
public override string ToString()
{
string snode="";

Binary file not shown.

View file

@ -1 +1 @@
!define VERSION '3.4.2.1786'
!define VERSION '3.4.2.1787'

View file

@ -28,6 +28,11 @@ namespace SyntaxVisitors
public SyntaxVisitorError(string resourcestring, SourceContext sc, params object[] values): base(StringResources.Get(resourcestring),"",sc,null)
{
}
public SyntaxVisitorError(string resourcestring, PascalABCCompiler.SyntaxTree.syntax_tree_node bad_node)
: base(StringResources.Get(resourcestring), "", bad_node.source_context, bad_node)
{
}
}
}

View file

@ -43,7 +43,7 @@ namespace SyntaxVisitors
base.visit(ws);
}
ident IdResult = null;
public override void visit(procedure_definition pd)
{
//this.CurrentMethod = pd;
@ -68,6 +68,19 @@ namespace SyntaxVisitors
}
}
/*if (pd.has_yield)
{
var dn = pd.DescendantNodes().OfType<ident>().Where(id => id.name.ToLower() == "result").FirstOrDefault();
if (dn != null)
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", dn);
}*/
if (pd.has_yield)
{
if (IdResult != null)
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", IdResult);
}
var innerPds = pd.DescendantNodes().OfType<procedure_definition>();
if (pd.has_yield && innerPds.Count() > 0
@ -89,6 +102,7 @@ namespace SyntaxVisitors
}
HasYields = false;
IdResult = null;
MethodsStack.Pop();
@ -97,15 +111,16 @@ namespace SyntaxVisitors
public override void visit(ident id)
{
if (MethodsStack.Count > 0 && id.name.ToLower() == "result")
{
IdResult = id;
//throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", id.source_context);
}
//if (CurrentMethod == null || !HasYields)
if (MethodsStack.Count == 0 || !HasYields)
{
return;
}
if (id.name.ToLower() == "result")
{
throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", id.source_context);
}
}
public override void visit(dot_node dn)

View file

@ -139,7 +139,7 @@ GENERIC_RECORDS_CANNOT_HAVE_EXPLICIT_LAYOUT=Генерик-записи не м
ATTRIBUTE_CANNOT_BE_GENERIC=Атрибуты не могут быть генерик-классами
EXTERNAL_METHOD_CANNOT_BE_DECLARED_IN_GENERIC_TYPE=external-методы нельзя описывать в генерик-классах
EXTERNAL_METHOD_CANNOT_BE_GENERIC=external-методы не могут быть генериками
WHERE_SPECIFIER_MISMATCH=Несоответствие спецификатора whеre спецификатору where базового классе​
WHERE_SPECIFIER_MISMATCH=Несоответствие спецификатора whеre спецификатору where базового класса
%PREFIX%=COMPILATIONERROR_
UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Ожидался модуль, а встречена библиотека
ASSEMBLY_{0}_READING_ERROR=Ошибка при чтении сборки '{0}'