-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathCompilerErrors.cs
More file actions
53 lines (43 loc) · 2.46 KB
/
CompilerErrors.cs
File metadata and controls
53 lines (43 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/
using System.Runtime.CompilerServices;
using OneScript.Language;
using OneScript.Localization;
namespace ScriptEngine.Compiler
{
public static class CompilerErrors
{
public static CodeError UseProcAsFunction() =>
Create("Использование процедуры, как функции", "Procedure called as function");
public static CodeError TooFewArgumentsPassed() =>
Create("Недостаточно фактических параметров", "Too many actual parameters");
public static CodeError TooManyArgumentsPassed() =>
Create("Слишком много фактических параметров", "Too many actual parameters");
public static CodeError MissedArgument() =>
Create("Пропущен обязательный параметр", "Missed mandatory parameter");
public static CodeError MissedImport(string symbol, string libName) =>
Create($"Свойство {symbol} принадлежит пакету {libName}, который не импортирован в данном модуле",
$"Property {symbol} belongs to package {libName} which is not imported in this module");
public static CodeError DuplicateLabelDefinition(string name) =>
Create($"Дублирование определения метки ~{name}",
$"Duplicate label definition ~{name}");
public static CodeError UndefinedLabel(string name) =>
Create($"Метка не определена ~{name}",
$"Undefined label ~{name}");
public static CodeError InvalidGotoTarget(string name) =>
Create($"На метку с указанным именем имеется недопустимый переход (~{name})",
$"Invalid goto target (~{name})");
private static CodeError Create(string ru, string en, [CallerMemberName] string errorId = default)
{
return new CodeError
{
ErrorId = errorId,
Description = BilingualString.Localize(ru, en)
};
}
}
}