Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6ff8bf
commit 587550b
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This is a straightforward coupling of RainCode and Moose, that serialises the parse tree produced by the former, in a MSE form consumable by the latter. | ||
|
||
Contributors: | ||
* [Darius Blasband](http://www.phidani.be/homes/darius/) | ||
* [Oscar Nierstrasz](http://scg.unibe.ch/staff/oscar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
MODULE Vadim; | ||
|
||
VAR | ||
Counter := 0; | ||
|
||
CACHE PROCEDURE Id(Node); | ||
BEGIN | ||
Counter := Counter + 1; | ||
RESULT := Counter; | ||
END Id; | ||
|
||
PROCEDURE INIT; | ||
BEGIN | ||
FILE1.Redirect('vadim.rse'); | ||
FILE1.WriteLn ('('); | ||
WriteModule; | ||
FOR IN ROOT.SubNodes | X IS ParagraphStatementBlock DO | ||
WriteParagraphEntry (X); | ||
END; | ||
FILE1.WriteLn (')'); | ||
FILE1.Redirect; | ||
END; | ||
|
||
PROCEDURE WriteModule; | ||
BEGIN | ||
FILE1.WriteLn ('( FAMIX.Class (id: ' , Id(ROOT), ')'); | ||
FILE1.WriteLn (" (name '", ROOT.OriginalModuleName , "')"); | ||
FILE1.WriteLn (')'); | ||
END; | ||
|
||
PROCEDURE WriteParagraphEntry (p); | ||
BEGIN | ||
FILE1.WriteLn ('( FAMIX.Method (id: ' , Id(p), ')'); | ||
FILE1.WriteLn (" (name '", p.Id.Image , "')"); | ||
FILE1.WriteLn (" (numberOfStatements ", (COUNT IN p.SubNodes :- X IS Statement) , ')'); | ||
FILE1.WriteLn (" (numberOfLines ", p.EndLineNr - p.LineNr + 1, ')'); | ||
FILE1.WriteLn (" (parentType (ref: ", Id(ROOT) , "))"); | ||
FILE1.WriteLn (')'); | ||
FOR IN p.SubNodes | X IS GotoStatement DO | ||
WriteGotoStatement (p, X); | ||
END; | ||
END; | ||
|
||
PROCEDURE WriteGotoStatement (p, g); | ||
VAR | ||
tt; | ||
BEGIN | ||
tt := g.Targets[1]; | ||
ASSERT tt CAN Ref; | ||
ASSERT tt.Ref <> VOID; | ||
FILE1.WriteLn ('( FAMIX.Invocation (id: ' , Id(g), ')'); | ||
FILE1.WriteLn (" (receiver (id: ", Id(tt.Ref) , "))"); | ||
FILE1.WriteLn (" (sender (id: ", Id(p) , "))"); | ||
FILE1.WriteLn (')'); | ||
END; | ||
|