Skip to content

Commit

Permalink
FIXED: совместимость со стабильной версией (#195, #314)
Browse files Browse the repository at this point in the history
Стабильная версия иначе интерпретировала псевдокомментарии и выдавала
на них ошибки компиляции. Для обеспечения совместимости внедрён костыль
в виде псевдокомментариев вида *$xDRIVE. После обновления стабильной
версии данный костыль нужно будет удалить.

Подробности в комментарии в коде.
  • Loading branch information
Mazdaywik committed Aug 23, 2021
1 parent 29e7c03 commit 01d3135
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/common/Escape.ref
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $ENTRY EscapeChar {
};
}

*$DRIVE EscapeChar
*$xDRIVE EscapeChar

$ENTRY EscapeString {
e.String = <Map &EscapeChar e.String>;
Expand Down
2 changes: 1 addition & 1 deletion src/common/FindFile.ref
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $EXTERN Map;
$EXTERN DirectorySeparator, PathSeparator;


*$DRIVE DS
*$xDRIVE DS
DS { = <DirectorySeparator> }


Expand Down
2 changes: 1 addition & 1 deletion src/compiler/Engine.ref
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ PatchASTSrcPos {
= <PatchAST s.FnPatch e.AST>;
}

*$SPEC PatchAST, PatchAST-Item, PatchAST-Body, PatchAST-Sentence,
*$xSPEC PatchAST, PatchAST-Item, PatchAST-Body, PatchAST-Sentence,
*$ PatchAST-Chain, PatchAST-Blocks, PatchAST-Expr

PatchAST {
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/Generator-RASL.ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $EXTERN PrintErr;

$INCLUDE "Opcodes";

*$DRIVE NumberFromOpcode, NumberFromBracket, BlockTypeNumber
*$xDRIVE NumberFromOpcode, NumberFromBracket, BlockTypeNumber

$ENTRY GenProgram-RASL {
(
Expand Down Expand Up @@ -93,19 +93,19 @@ BytesFromStringList {
>;
}

*$DRIVE BytesFromString
*$xDRIVE BytesFromString

BytesFromString {
e.String = <Ord e.String>;
}

*$DRIVE Asciiz
*$xDRIVE Asciiz

Asciiz {
e.String = <BytesFromString e.String> 0;
}

*$DRIVE PutBlock
*$xDRIVE PutBlock

PutBlock {
s.Type e.Bytes =
Expand All @@ -126,7 +126,7 @@ PutWordLE {
= <PutWordLE e.Bytes s.ValueLow s.ValueHigh>;
}

*$DRIVE NameWithSign-Bytes
*$xDRIVE NameWithSign-Bytes

NameWithSign-Bytes {
GN-Entry e.Name = <Asciiz '*' <DisplayName e.Name>>;
Expand Down Expand Up @@ -389,7 +389,7 @@ GenCommand-RASL {
<PutCommand CmdFail>;
}

*$DRIVE PutCommand
*$xDRIVE PutCommand

PutCommand {
s.Symbolic = (<NumberFromOpcode s.Symbolic> 0 0 0);
Expand All @@ -410,7 +410,7 @@ PutCommand {
};
}

*$DRIVE CreateCommandTag
*$xDRIVE CreateCommandTag

CreateCommandTag {
ElOpenBracket = ElBracket;
Expand All @@ -423,7 +423,7 @@ CreateCommandTag {
s.Other = s.Other;
}

*$DRIVE CreateCommandInfo
*$xDRIVE CreateCommandInfo

CreateCommandInfo {
ElChar s.Char = <Ord s.Char>;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/GenericMatch.ref
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ AddContractions-Spec-Symm {
<AddContraction t.toAdd (t.Contraction*) t.Equation* (t.Assign*)>
== PRTC
*/
*$DRIVE AddContraction-Spec, AddContraction-Spec-Symm
*$xDRIVE AddContraction-Spec, AddContraction-Spec-Symm

AddContraction-Spec {
t.toAdd (s.OpenFlag e.Contrs) e.Clashes (e.Assigns)
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/OptTree-Drive-Expr.ref
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ ColdAll {

MaxCntNodes { = 100 }

*$DRIVE MaxCntNodes
*$xDRIVE MaxCntNodes

MaxTreeDepth { = 20 }

*$DRIVE MaxTreeDepth
*$xDRIVE MaxTreeDepth

IncWithMax {
s.Cnt s.Max, <Compare s.Max s.Cnt> : '+' = <Add s.Cnt 1>;
Expand Down Expand Up @@ -471,7 +471,7 @@ FindOptInfo-Aux {
((e.Name) Sentences <DropLeft e.Sentences s.Drop>);
}

*$DRIVE CutSUF
*$xDRIVE CutSUF

CutSUF {
e.Prefix SUF = e.Prefix;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/OptTree-StopRelation.ref
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ENTRY OptTree-CheckExprStopRelation {
(e.CurrentExpr) e.HistoryExpr = <Trace False False>;
}

*$DRIVE Trace
*$xDRIVE Trace

Trace {
*/*
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/OptTree.ref
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Int-Cond {
s.Opt = True;
}

*$DRIVE Int-Cond
*$xDRIVE Int-Cond

Int-Cond-Or {
t.Cond e.Flags
Expand Down Expand Up @@ -283,7 +283,7 @@ Int-LoopForWarmFunctions {
(e.Defines) e.Code s.Cycles (e.AST) = s.Cycles e.AST;
}

*$DRIVE Int-Lookup
*$xDRIVE Int-Lookup

Int-Lookup {
s.ProcName (define s.ProcName e.Body) e._ = e.Body;
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/R5-Lexer.ref
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ IncLine {
(RowCol s.Line s.Col) = (RowCol <Inc s.Line> 1);
}

*$DRIVE IncCol
*$xDRIVE IncCol

IncCol {
(RowCol s.Line s.Col) = (RowCol s.Line <Inc s.Col>);
Expand Down Expand Up @@ -279,7 +279,7 @@ DoScan-BuildKeyword {
<DoScan <IncCol t.Pos Len e.KeywordChars> (e.Line) e.Lines>;
}

*$DRIVE EasterEgg
*$xDRIVE EasterEgg

EasterEgg {
t.Pos s.Char e.Text = (TkChar t.Pos s.Char) <EasterEgg t.Pos e.Text>;
Expand Down Expand Up @@ -466,7 +466,7 @@ HexDigit {
};
}

*$DRIVE DoHexDigit
*$xDRIVE DoHexDigit

DoHexDigit {
s.Digit e.Samples s.Val s.Digit = s.Val;
Expand Down
24 changes: 21 additions & 3 deletions src/compiler/R5-Parser.ref
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ ParsePseudocomment {
t.Pos s.Node (/* scanned */) t.ErrorList e.Tokens
>;

/*
TODO: Стабильная версия 3.3 по-другому парсит ключевые слова и сообщает
об ошибках в них (не предупреждениях). Поэтому, чтобы можно было собрать
текущую версию и стабильной, и самой собой, для каждого ключевого слова
создаём синоним вида *$xDRIVE или *$xSPEC. Он игнорируется стабильной
версией 3.3 и работает в рабочей.

TODO: после обновления стабильной версии нужно будет удалить поддержку
псевдокомментариев *$x..., а также почистить исходники. Для этой цели
добавлена заготовка предупреждения.
*/
t.ErrorList t.Pos (TkName t.NamePos 'x' e.Name) e.Tokens
* = <EL-AddWarningAt t.ErrorList deprecated t.NamePos '$x... keyword'>
* : t.ErrorList^
= <ParsePseudocomment
t.ErrorList t.Pos (TkName t.NamePos e.Name) e.Tokens
>;

t.ErrorList t.Pos e._unrecognized
= t.ErrorList /* пропускаем неопознанный псевдокомментарий */;
}
Expand Down Expand Up @@ -769,14 +787,14 @@ Expression {
>;
}

*$DRIVE TokenChain, Expression
*$xDRIVE TokenChain, Expression

TokenChain {
t.ErrorList s.Mode s.Kind e.Tokens
= <DoTokenChain s.Mode s.Kind t.ErrorList (/* collected */) e.Tokens>
}

*$NOOPT DoTokenChain
*$xNOOPT DoTokenChain

DoTokenChain {
s.Mode s.Kind t.ErrorList (e.Collected) t.NextToken e.Tokens
Expand Down Expand Up @@ -1031,7 +1049,7 @@ Expression-CheckBrackets {
= t.ErrorList t.Expression e.Tokens;
}

*$DRIVE ClassicError
*$xDRIVE ClassicError

ClassicError {
t.ErrorList Classic t.Pos e.Message
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/main.ref
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Main-SwValidCommandLine {
= <ReportErrors t.CommandLineSource NoConfig e.Errors>;
}

*$DRIVE ReportErrors, ReportWarnings, ReportMessages
*$xDRIVE ReportErrors, ReportWarnings, ReportMessages

ReportErrors {
t.CommandLineSource t.Config e.Errors
Expand Down Expand Up @@ -348,7 +348,7 @@ RenameLocations-Aux {
= e.NewLocations;
}

*$DRIVE AddNumSuffix
*$xDRIVE AddNumSuffix

AddNumSuffix {
0 e.Output = e.Output;
Expand Down Expand Up @@ -946,7 +946,7 @@ DoCopyPrefix {
}
}

*$DRIVE LinkError
*$xDRIVE LinkError

LinkError {
t.Config e.Message
Expand Down

0 comments on commit 01d3135

Please sign in to comment.