Skip to content

Commit

Permalink
as sent by Darius
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Aug 27, 2012
1 parent f6ff8bf commit 587550b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hackathon/raincode-moose/README.md
@@ -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)
56 changes: 56 additions & 0 deletions hackathon/raincode-moose/vadim.rcs
@@ -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;

0 comments on commit 587550b

Please sign in to comment.