Skip to content

Commit

Permalink
Адаптация дерева к Рефалу-05 (#5, Mazdaywik/Refal-05#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazdaywik committed Apr 3, 2019
1 parent 61abf03 commit 33065bc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 33 deletions.
11 changes: 6 additions & 5 deletions docs/Refal5-AST.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

t.Pattern, t.Result ::= (t.Term*)
t.Term ::=
(Compound e.Chars*)
| (Number s.Number)
| (Char s.Char)
(Symbol Word t.SrcPos e.Chars*)
| (Symbol Number s.Number)
| (Symbol Char s.Char)
| (Variable t.SrcPos s.VarType e.Index)
| (Brackets t.Term*)
| (Call t.SrcPos (e.Function) t.Terms*)
Expand All @@ -43,8 +43,9 @@
частью (`RETURN`), либо вызовом блока (`CALL-BLOCK`).
* `t.Result` — результатное выражение.
* `t.Term` — терм выражения, может быть:
- `Compound` — словом (составным символом),
- `Number` — макроцифрой,
- `Symbol Word` — словом (составным символом),
- `Symbol Number` — макроцифрой,
- `Symbol Char` — литерой,
- `Variable` — переменной,
- `Brackets` — скобочным термом,
- `Call` — вызовом функции (недопустим внутри образца).
Expand Down
8 changes: 4 additions & 4 deletions lib/Refal5-AST.ref
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

t.Pattern, t.Result ::= (t.Term*)
t.Term ::=
(Compound e.Chars*)
| (Number s.Number)
| (Char s.Char)
(Symbol Word t.SrcPos e.Chars*)
| (Symbol Number s.Number)
| (Symbol Char s.Char)
| (Variable t.SrcPos s.VarType e.Index)
| (Brackets t.Term*)
| (Call t.SrcPos (e.Function) t.Terms*)
Expand All @@ -22,7 +22,7 @@

*$EENUM SpecialComment, Extern, Function, Entry, Local
*$EENUM RETURN, CALL-BLOCK, Condition
*$EENUM Compound, Number, Char, Variable, Brackets, Call
*$EENUM Symbol, Word, Number, Char, Variable, Brackets, Call


/**
Expand Down
10 changes: 5 additions & 5 deletions lib/Refal5-Parser.ref
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $EXTERN OneOf, Map;
$EXTERN Builtins;
*$EXTERN SpecialComment, Extern, Function, Entry, Local
*$EXTERN RETURN, CALL-BLOCK, Condition
*$EXTERN Compound, Number, Char, Variable, Brackets, Call
*$EXTERN Symbol, Word, Number, Char, Variable, Brackets, Call


*$FROM Library
Expand Down Expand Up @@ -483,22 +483,22 @@ DoExpression {
{
(TkName t.Pos e.Name) =
<DoExpression
s.Kind (e.Errors) (e.Collected (Compound e.Name)) e.Tokens
s.Kind (e.Errors) (e.Collected (Symbol Word t.Pos e.Name)) e.Tokens
>;

(TkCompound t.Pos e.Symbols) =
<DoExpression
s.Kind (e.Errors) (e.Collected (Compound e.Symbols)) e.Tokens
s.Kind (e.Errors) (e.Collected (Symbol Word t.Pos e.Symbols)) e.Tokens
>;

(TkMacroDigit t.Pos s.Number) =
<DoExpression
s.Kind (e.Errors) (e.Collected (Number s.Number)) e.Tokens
s.Kind (e.Errors) (e.Collected (Symbol Number s.Number)) e.Tokens
>;

(TkChar t.Pos s.Char) =
<DoExpression
s.Kind (e.Errors) (e.Collected (Char s.Char)) e.Tokens
s.Kind (e.Errors) (e.Collected (Symbol Char s.Char)) e.Tokens
>;

(TkVariable t.Pos s.VarType e.Index) =
Expand Down
14 changes: 7 additions & 7 deletions lib/Refal5-Plainer.ref
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*$FROM Refal5-AST
*$EXTERN Extern, Function, SpecialComment, Entry, Local, RETURN, Condition
*$EXTERN CALL-BLOCK, Brackets, Call, Compound, Number, Char, Variable
*$EXTERN CALL-BLOCK, Brackets, Call, Symbol, Word, Number, Char, Variable

*$FROM Library
*$EXTERN False, True
Expand Down Expand Up @@ -218,7 +218,7 @@ AppendTerm {
}

InlineTerm {
(s.Type e.Value) = <PlainByType s.Type e.Value>;
(s.Type e.Value) = <PlainTerm s.Type e.Value>;

';' = ';';
}
Expand Down Expand Up @@ -247,14 +247,14 @@ MultilineTerm-Prefix {
(e.Indent '>' e.Suffix);

(s.Type e.Value)
= (e.Prefix <PlainByType s.Type e.Value> e.Suffix);
= (e.Prefix <PlainTerm s.Type e.Value> e.Suffix);
};
}

PlainByType {
Compound e.Chars = <PlainCompound e.Chars>;
Number s.Number = <PlainNumber s.Number>;
Char s.Char = <PlainChar s.Char>;
PlainTerm {
Symbol Word t.SrcPos e.Chars = <PlainCompound e.Chars>;
Symbol Number s.Number = <PlainNumber s.Number>;
Symbol Char s.Char = <PlainChar s.Char>;
Variable t.SrcPos s.Type e.Index = <PlainVariable t.SrcPos s.Type e.Index>;
Call t.SrcPos (e.Function) e.Arg = <PlainCall t.SrcPos (e.Function) e.Arg>;
Brackets e.Expr = <PlainBrackets e.Expr>;
Expand Down
15 changes: 3 additions & 12 deletions lib/Refal5-Transformer.ref
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $EXTERN Map, Unique;
*$FROM Refal5-AST
$EXTERN Builtins;
*$EXTERN Function, Extern, SpecialComment, CALL-BLOCK, RETURN, Call, Local
*$EXTERN Condition, Brackets, Variable, Compound, Number, Char
*$EXTERN Condition, Brackets, Variable, Symbol, Word, Number, Char

*$FROM Library
*$EXTERN True, False
Expand Down Expand Up @@ -402,9 +402,7 @@ DoPatternSteps {
}

HardItem {
(e.BoundEVariables) (Compound e.Compound) = True;
(e.BoundEVariables) (Number s.Number) = True;
(e.BoundEVariables) (Char s.Char) = True;
(e.BoundEVariables) (Symbol s.Type e.Info) = True;

(e.BoundEVariables) (Variable t.SrcPos 's' e.Index) = True;
(e.BoundEVariables) (Variable t.SrcPos 't' e.Index) = True;
Expand All @@ -422,7 +420,7 @@ $ENTRY transformer_BindBrackets {

DoBindBrackets {
(t.MultiBracket e.Scanned) t.Symbol e.Tail
, <Symbol t.Symbol> : True
, t.Symbol : (Symbol s.Type e.Info)
= <DoBindBrackets (t.MultiBracket e.Scanned t.Symbol) e.Tail>;

(t.MultiBracket e.Scanned) (Variable t.SrcPos s.Type e.Index) e.Tail
Expand Down Expand Up @@ -818,10 +816,3 @@ DoNewName {
e.Names = ((e.NewName) e.Names) e.NewName;
};
}

Symbol {
(Compound e.Chars) = True;
(Number s.Number) = True;
(Char s.Char) = True;
t.Other = False;
}

0 comments on commit 33065bc

Please sign in to comment.