Skip to content

Commit

Permalink
Устаревшие узлы дерева переименованы в Legacy… (#314, #318)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazdaywik committed Aug 22, 2021
1 parent fbc18f4 commit 84c8d7b
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 48 deletions.
55 changes: 33 additions & 22 deletions src/compiler/Checker.ref
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ PrepareMessage {
DanglingDrive e.Name = '$DRIVE ' e.Name '; drive label for missed function';

NativeOptimizable s.Label e.Name
= 'Function ' e.Name ' can\'t be $' <Upper <Explode s.Label>>;
= s.Label
: {
LegacyDrive = '$DRIVE';
LegacyInline = '$INLINE';
LegacySpec = '$SPEC';
}
: e.Keyword
= 'Function ' e.Name ' can\'t be ' e.Keyword;

/* Ошибки специализации */
RedefineSpec e.FnName = 'Specialization of function ' e.FnName 'is redefined';
Expand Down Expand Up @@ -139,11 +146,11 @@ CheckPseudofunctions {
= <Map
{
(s.Tag t.SrcPos s.ScopeClass e.Name)
, Drive Inline Intrinsic : e._ s.Tag e._
, LegacyDrive LegacyInline Intrinsic : e._ s.Tag e._
, <Pseudofunctions> : e._ (e.Name) e._
= (Error t.SrcPos TaggedPseudofunction s.Tag e.Name);

(Spec t.SrcPos (e.Name) e._)
(LegacySpec t.SrcPos (e.Name) e._)
, <Pseudofunctions> : e._ (e.Name) e._
= (Error t.SrcPos TaggedPseudofunction Spec e.Name);

Expand Down Expand Up @@ -216,11 +223,11 @@ CheckSpecs {
* Проверка переопределения специализации
CheckSpecs-Redefine {
e.AST-B
(Spec t.SrcPos1 (e.Name) e.Pattern1) e.AST-M
(Spec t.SrcPos2 (e.Name) e.Pattern2) e.AST-E
(LegacySpec t.SrcPos1 (e.Name) e.Pattern1) e.AST-M
(LegacySpec t.SrcPos2 (e.Name) e.Pattern2) e.AST-E
= <CheckSpecs-Redefine
e.AST-B
(Spec t.SrcPos1 (e.Name) e.Pattern1) e.AST-M
(LegacySpec t.SrcPos1 (e.Name) e.Pattern1) e.AST-M
(Error t.SrcPos2 RedefineSpec e.Name) e.AST-E
>;

Expand All @@ -232,13 +239,13 @@ CheckSpecs-Formats {
e.AST
= <Map
{
(Spec t.SrcPos (e.Name) e.Pattern)
(LegacySpec t.SrcPos (e.Name) e.Pattern)
= <IsHardPattern e.Pattern>
: {
True
= <CheckRepeatedVariables e.Pattern>
: {
/* пусто */ = (Spec t.SrcPos (e.Name) e.Pattern);
/* пусто */ = (LegacySpec t.SrcPos (e.Name) e.Pattern);

e.Errors = e.Errors;
};
Expand Down Expand Up @@ -353,7 +360,7 @@ FindVariables {
* Проверка, что упоминаемые функции определены
CheckSpecs-Functions {
e.AST-B
(Spec t.SrcPos1 (e.Name) e.Pattern) e.AST-M
(LegacySpec t.SrcPos1 (e.Name) e.Pattern) e.AST-M
(Function t.SrcPos2 s.ScopeClass (e.Name) e.Body) e.AST-E
= <ValidBodyForSpec (e.Name) (e.Pattern) e.Body>
: {
Expand All @@ -380,7 +387,7 @@ CheckSpecs-Functions {

e.AST-B
(Function t.SrcPos1 s.ScopeClass (e.Name) e.Body) e.AST-M
(Spec t.SrcPos2 (e.Name) e.Pattern) e.AST-E
(LegacySpec t.SrcPos2 (e.Name) e.Pattern) e.AST-E
= <ValidBodyForSpec (e.Name) (e.Pattern) e.Body>
: {
True =
Expand All @@ -404,7 +411,7 @@ CheckSpecs-Functions {
: e.AST
= <CheckSpecs-Functions e.AST>;

e.AST-B (Spec t.SrcPos (e.Name) e.Pattern) e.AST-E
e.AST-B (LegacySpec t.SrcPos (e.Name) e.Pattern) e.AST-E
= <CheckSpecs-Functions
e.AST-B (Error t.SrcPos OrphanSpec e.Name) e.AST-E
>;
Expand All @@ -421,7 +428,8 @@ ValidBodyForSpec {
: (s.BoolResult e.Messages)
= s.BoolResult e.Messages;

(e.Name) t.Pattern NativeBody e.Code = False (NativeOptimizable Spec e.Name);
(e.Name) t.Pattern NativeBody e.Code
= False (NativeOptimizable LegacySpec e.Name);
}

ValidBodyForSpec-CheckSentensePattern {
Expand Down Expand Up @@ -543,11 +551,11 @@ SeparateDefines {
(e.Declarations) (Entry t.SrcPos GN-Entry e.Name) =
(e.Declarations (Entry t.SrcPos e.Name));

(e.Declarations) (Inline t.SrcPos s.ScopeClass e.Name) =
(e.Declarations (Inline t.SrcPos e.Name));
(e.Declarations) (LegacyInline t.SrcPos s.ScopeClass e.Name) =
(e.Declarations (LegacyInline t.SrcPos e.Name));

(e.Declarations) (Drive t.SrcPos s.ScopeClass e.Name) =
(e.Declarations (Drive t.SrcPos e.Name));
(e.Declarations) (LegacyDrive t.SrcPos s.ScopeClass e.Name) =
(e.Declarations (LegacyDrive t.SrcPos e.Name));

(e.Declarations) (Intrinsic t.SrcPos s.ScopeClass e.Name) =
(e.Declarations (Intrinsic t.SrcPos e.Name));
Expand Down Expand Up @@ -587,11 +595,11 @@ FindInvalidDriveInline {
/* находим все $DRIVE и $INLINE */
= <MapAccum
{
(e.DriveInline) (Inline t.SrcPos e.Name)
= (e.DriveInline (Inline t.SrcPos e.Name));
(e.DriveInline) (LegacyInline t.SrcPos e.Name)
= (e.DriveInline (LegacyInline t.SrcPos e.Name));

(e.DriveInline) (Drive t.SrcPos e.Name)
= (e.DriveInline (Drive t.SrcPos e.Name));
(e.DriveInline) (LegacyDrive t.SrcPos e.Name)
= (e.DriveInline (LegacyDrive t.SrcPos e.Name));

(e.DriveInline) t.OtherDeclaration
= (e.DriveInline) t.OtherDeclaration;
Expand Down Expand Up @@ -643,8 +651,11 @@ FindInvalidDriveInline {

= <Map
{
(Inline t.SrcPos e.Name) = (Error t.SrcPos DanglingInline e.Name);
(Drive t.SrcPos e.Name) = (Error t.SrcPos DanglingDrive e.Name);
(LegacyInline t.SrcPos e.Name)
= (Error t.SrcPos DanglingInline e.Name);

(LegacyDrive t.SrcPos e.Name)
= (Error t.SrcPos DanglingDrive e.Name);
}
e.InvalidDriveInline
>
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/Desugaring-UnCondition.ref
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ UnCondition-Sentence {
)
)
)
(Drive e.CheckFunction)
(Spec e.CheckFunction)
(GROUP Drives (e.CheckFunction))
(GROUP Specs (e.CheckFunction))
t.CheckFunction e.OpenEFunctions;
}

Expand Down Expand Up @@ -543,7 +543,7 @@ MakeOpenE-ForwardNext {
((e.T1) ((CallBrackets (Symbol Name e.NextName) e.T2)))
((e.T3) ((CallBrackets (Symbol Name e.ContName) e.T4)))
)
(Drive e.CurrentForwardName)
(GROUP Drives (e.CurrentForwardName))
(Function (e.NextName) Sentences
(
(e.T5)
Expand Down
24 changes: 14 additions & 10 deletions src/compiler/Desugaring.ref
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $ENTRY Pass-RemovePos {

(NativeBlock t.SrcPos e.Code) = (NativeBlock t.SrcPos e.Code);

(Spec t.SrcPos (e.Name) e.Pattern) = (Spec e.Name);
(LegacySpec t.SrcPos (e.Name) e.Pattern) = (LegacySpec e.Name);

(s.EnumSwapDeclaration t.SrcPos s.ScopeClass e.Name)
= (s.EnumSwapDeclaration s.ScopeClass e.Name);
Expand Down Expand Up @@ -159,8 +159,12 @@ $ENTRY Pass-ExtractEntries {
= (e.Entries <Entry s.ScopeClass e.Name>)
(Function (e.Name) e.Body);

(e.Entries) (Drive s.ScopeClass e.Name) = (e.Entries) (Drive e.Name);
(e.Entries) (Inline s.ScopeClass e.Name) = (e.Entries) (Inline e.Name);
(e.Entries) (LegacyDrive s.ScopeClass e.Name)
= (e.Entries) (LegacyDrive e.Name);

(e.Entries) (LegacyInline s.ScopeClass e.Name)
= (e.Entries) (LegacyInline e.Name);

(e.Entries) (Intrinsic s.ScopeClass e.Name)
= (e.Entries) (Intrinsic e.Name);

Expand Down Expand Up @@ -741,7 +745,7 @@ ExtractNested-Result-Term {
(/* нет захваченных переменных */) e.Body^
= e.Body
: {
Sentences e.Sentences = (Drive e.ClosureName);
Sentences e.Sentences = (GROUP Drives (e.ClosureName));
NativeBody e.NativeBody = /* нет меток */;
}
: e.DriveLabelOpt
Expand All @@ -764,8 +768,8 @@ ExtractNested-Result-Term {
e.Sentences
>
)
(Drive e.ClosureName)
(Spec e.ClosureName)
(GROUP Drives (e.ClosureName))
(GROUP Specs (e.ClosureName))
<Reduce
(&CheckBorrowed (e.ScopeVars))
(e.BorrowedVars) e.NestedBorrowedVars
Expand Down Expand Up @@ -803,15 +807,15 @@ Pass-CollectDeclarations {
(Declaration GN-Local e._) = /* игнорируем */;
(Declaration GN-Entry e.Name) = (GROUP Externs (e.Name));

(Drive e.Name) = (GROUP Drives (e.Name));
(Inline e.Name) = (GROUP Inlines (e.Name));
(LegacyDrive e.Name) = (GROUP Drives (e.Name));
(LegacyInline e.Name) = (GROUP Inlines (e.Name));
(Intrinsic e.Name) = (GROUP Intrinsics (e.Name));
(Spec e.Name) = (GROUP Specs (e.Name));
(LegacySpec e.Name) = (GROUP Specs (e.Name));

(Function (e.Name) e.Body)
= (GROUP DefinedFunctions (e.Name)) (Function (e.Name) e.Body);

t.Other = t.Other
t.Other = t.Other;
}
e.AST
>
Expand Down
9 changes: 5 additions & 4 deletions src/compiler/Engine.ref
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,17 @@ PatchAST-Item {
s.FnPatch (Include t.SrcPos e.IncludeName) = /* пропускаем */;

s.FnPatch (s.Label t.SrcPos s.ScopeClass e.Name)
, Enum Swap Declaration Entry Inline Drive Intrinsic Meta : e._ s.Label e._
, Enum Swap Declaration Entry LegacyInline LegacyDrive Intrinsic Meta
: e._ s.Label e._
= (s.Label
<s.FnPatch SrcPos t.SrcPos>
s.ScopeClass
<s.FnPatch Name e.Name>
);

s.FnPatch (Spec t.SrcPos (e.Name) e.Pattern)
s.FnPatch (LegacySpec t.SrcPos (e.Name) e.Pattern)
= (
Spec <s.FnPatch SrcPos t.SrcPos> (<s.FnPatch Name e.Name>)
LegacySpec <s.FnPatch SrcPos t.SrcPos> (<s.FnPatch Name e.Name>)
<PatchAST-Expr s.FnPatch e.Pattern>
);
}
Expand Down Expand Up @@ -620,7 +621,7 @@ CreateMetaFunctions {
= (e.FunctionNames (e.Name))
(Declaration t.SrcPos GN-Entry '__Meta_' e.Name)
(Declaration t.SrcPos GN-Entry '__Step-Drop')
(Inline t.SrcPos s.ScopeClass e.Name)
(LegacyInline t.SrcPos s.ScopeClass e.Name)
(Function
t.SrcPos s.ScopeClass (e.Name) Sentences
(
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/R5-Parser.ref
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $EXTERN EL-AddErrorAt, EL-AddWarningAt;
t.Include ::= (Include t.Pos e.Name)
t.NativeBlock ::= (NativeBlock t.Pos e.Code)
t.Ident ::= (Ident t.SrcPos e.Name)
t.SpecUnit = (Spec t.Pos (e.Name) e.Pattern)
t.SpecUnit = (LegacySpec t.Pos (e.Name) e.Pattern)

t.Function ::= (Function t.SrcPos s.ScopeClass (e.Name) e.Body)
e.Body ::= Sentences t.Sentence* | NativeBody t.Pos e.Code
Expand Down Expand Up @@ -208,11 +208,11 @@ TkEntryL {
}

TkInline {
t.Pos e.Name = (Inline t.Pos GN-Local e.Name)
t.Pos e.Name = (LegacyInline t.Pos GN-Local e.Name)
}

TkDrive {
t.Pos e.Name = (Drive t.Pos GN-Local e.Name)
t.Pos e.Name = (LegacyDrive t.Pos GN-Local e.Name)
}

TkMeta {
Expand Down Expand Up @@ -306,7 +306,7 @@ Include {
<Specialization t.ErrorList s.Mode s.Tag e.Tokens>
== t.ErrorList (t.SpecUnit) e.Tokens

t.SpecUnit = (Spec t.Pos (e.Name) e.Pattern)
t.SpecUnit = (LegacySpec t.Pos (e.Name) e.Pattern)

*/

Expand All @@ -316,7 +316,7 @@ Specialization {
: t.ErrorList^ (e.Pattern) e.Tokens^
= <Expect t.ErrorList TkSemicolon ('missed semicolon') e.Tokens>
: t.ErrorList^ e.Tokens^
= t.ErrorList ((Spec t.Pos (e.Name) e.Pattern)) e.Tokens;
= t.ErrorList ((LegacySpec t.Pos (e.Name) e.Pattern)) e.Tokens;

t.ErrorList s.Mode t.Pos t.Unexpected e.Tokens
= <UnexpectedToken t.ErrorList t.Unexpected 'function name'>
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@
| t.NativeBlock | t.Ident | t.SpecUnit
t.Extern ::= (Declaration t.Pos GN-Entry e.Name)
t.SingleDeclaration ::= (s.SingleDeclarationTag t.Pos s.ScopeClass e.Name)
s.SingleDeclarationTag ::= Enum | Swap | Inline | Drive | Meta
s.SingleDeclarationTag ::= Enum | Swap | LegacyInline | LegacyDrive | Meta
t.Include ::= (Include t.Pos e.Name)
t.NativeBlock ::= (NativeBlock t.Pos e.Code)
t.Ident ::= (Ident t.SrcPos e.Name)
t.SpecUnit ::= (Spec t.Pos (e.Name) e.Pattern)
t.SpecUnit ::= (LegacySpec t.Pos (e.Name) e.Pattern)

t.Function ::= (Function t.SrcPos s.ScopeClass (e.Name) e.Body)
e.Body ::=
Expand Down Expand Up @@ -177,7 +177,7 @@
(`(Declaration …)`) всегда имеют область видимости `GN-Extern`. И наоборот,
списки `$INLINE` и `$DRIVE` есть только в Рефале-5λ.

Для списков `Inline`, `Drive` и `Meta` тег области видимости всегда
Для списков `LegacyInline`, `LegacyDrive` и `Meta` тег области видимости всегда
`GN-Local`, в дерево он добавлен для общности.

Подробное описание большинства элементов дерева в проходе 2Б.
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/SR-Parser.sref
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ ParseSpec {
: t.ErrorList^ (e.Pattern) e.Tail^
= <Expect #TkSemicolon (';') t.ErrorList e.Tail>
: t.ErrorList^ e.Tail^
= ((#Spec s.LnNum (e.Name) e.Pattern)) t.ErrorList e.Tail;
= ((#LegacySpec s.LnNum (e.Name) e.Pattern)) t.ErrorList e.Tail;

t.ErrorList t.Unexpected e.Tail
= (/* ничего не генерируем */)
Expand Down

0 comments on commit 84c8d7b

Please sign in to comment.