manipulations on source

coordinatedcapableΛογισμικό & κατασκευή λογ/κού

4 Νοε 2013 (πριν από 3 χρόνια και 11 μήνες)

178 εμφανίσεις

Jean
-
Christophe Real

Automatic analysis &
manipulations on source
code

What is RainCode ?


A tool that allows you to find, measure, count, detect
non
-
trivial things in your code


A tool that can take corrective and preventive action in
your code


Implement best practice in a tool


A tool that can automate major transformations on
your code


Up to change from one language to another

Typical usages:


Migration (translation) systems


Ideal to COBOL


Documentation generator


Roadmap

(
Ada,
COBOL, PL/1
, 4GL
)


Quality control & complianceware


Portability assessment

How RainCode ?


Read (
Ada,
C
OBOL

, C, C++, Java,
PL/1, CSP
,
Ideal
, …
) programs and
build an abstract tree


Provide a scripting language to query
the tree in a powerful way


Are
all function return types constrained

?

Where RainCode ?


RainCode comes in two flavours:


A batch version, portable (Unix, Linux,
Solaris, HP Unix,
NT, OS/2, MVS), using
command
-
line switches


A GUI version under NT, where facilities
(scripting components) are attached to GUI
elements (buttons)

The scripting language


Dynamically typed Pascal
-
like language


Quantifiers


Modularity


Set
-
based operations (membership,
union, difference, etc…)

Example 1
: No Goto

ON
GotoStatement

[
s
] DO


OUT.WriteLn
(
«

Goto found at », s
.LineNr);


END;


Example 2: Global variables

PROCEDURE FindGlobalVariables;


BEGIN


FOR el IN ROOT.SubNodes


| X IS PackageSpecification DO


FOR decl IN el.Declarations


| X IS ObjectDeclaration DO


RESULT := RESULT & decl.Ids;


END;


END;


END FindGlobalVariables;


Example
3: Patch global
variable names


PROCEDURE PatchNames;


BEGIN


FOR v IN FindGlobalVariables DO


IF NOT STR.StartsWith(v.Image, «G_») THEN


ChangeName(v);


END;


END;


END PatchNames;

Example
3: continued


PROCEDURE ChangeName(var);


BEGIN


FOR r IN ROOTS DO


FOR u IN r.SubNodes | (X IS Identifier)


AND (X CAN Ref) AND (X.Ref = var) DO


r.Patch.ReplaceNt(u, "G_" & u.Image);


END;


END;


PATCH.ReplaceNt(var, "G_" & var.Image);


END ChangeName;


Example
4: Max nesting
level


PROCEDURE MaxNesting;


BEGIN


RESULT := MATH.Max(


(ROOT.SubNodes | X IS Statement )


|| COUNT s IN X.Ancestors


:
-

s IS Statement);


END MaxNesting;

Products in demo


RainCode Engine for Ada


RainCode Checker for Ada


RainCode Roadmap for Ada


XmlBooster for Ada

Jean
-
Christophe Real

jcreal@raincode.com

Questions ?

Come and see us

www.raincode.com