// Uncolored, plain source file: UncontinF77.java
// UncontinF77.java by Steven R. Brandt
// <p>
// An example file distributed with com.stevesoft.pat
// and com.stevesoft.pat.apps
// <p>
// This software comes without express or implied warranty.
// No claim is made about the suitability of this software for
// any purpose and neither I nor SteveSoft shall be liable for
// damages suffered by the user of this software.
import com.stevesoft.pat.*;
import java.io.*;
// Fortran 77 is certainly a painful language to read
// for java, C++, or even C programmers. The language
// was designed around the concept of the punch-card and
// what column you are on matters. This means that lines
// have a maximum length of 72 characters (the last 8 are
// automatically comments). To get around this limit,
// the compiler counts any line beginning with 5 spaces
// followed by a non-space character to be a continuation
// of the previous line. This toy program "uncontinues"
// a line of F77 by removing the string "\n ." from
// the file. This is an example of a multi-line rule.
//
// Unfortunately for us scientists, we are often forced
// to use F77 because it often gets optimized the best.
// Frequently, it is assumed that we like F77. Would
// someone please implement high-performance java?
public class UncontinF77 {
public static void main(String[] s) {
try {
Regex r = new Regex("\r?\n {5}\\S[ \t]*"," ");
OutputStreamWriter osw = new OutputStreamWriter(System.out);
RegexWriter rw = new RegexWriter(r,osw);
PrintWriter pw = new PrintWriter(rw);
pw.println(" This is an f77-style");
pw.println(" & continued");
pw.println(" & line.");
pw.println(" RegexWriter can easily");
pw.println(" & make remove the continuation");
pw.println(" & thing.");
pw.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}