User:Kevin Reid/Converting Java code

From Erights

< User:Kevin Reid
Revision as of 13:28, 6 July 2008 by Kevin Reid (Talk)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

While converting Java files to E for E-on-CL, I developed this set of regular expression replacements to reduce the work needed. Apply them in sequence.

TODO: convert this into a program

^import (.*)\.(.*);$

def make$2 := <import:$1.make$2>
def $2 := make$2.asType()
----------------------------------------------------------------------------
^( *)//
$1#
----------------------------------------------------------------------------
public class (.)(.*) extends (.*) \{

def make$1$2() implements DeepFrozen {
    def \L$1\E$2 extends $3 {
----------------------------------------------------------------------------
public class (.)(.*) \{

def make$1$2() implements DeepFrozen {
    def \L$1\E$2 {
----------------------------------------------------------------------------
public (\w+) (\w+)\(([^()]*?)\) \{
to $2($3) :$1 {
----------------------------------------------------------------------------
to(.*)\(((?:.*?, )*)([A-Z]\w*|int|long|float|double) ([a-z]\w*)
to$1($2$4 :$3
----------------------------------------------------------------------------
 :Object
 :any
----------------------------------------------------------------------------
 = 
 := 
----------------------------------------------------------------------------
private final (\w+) (\w+);
def $2 :$1 := ...
----------------------------------------------------------------------------
new ([A-Z]\w*)\(
make$1\(
Personal tools
more tools