/* SCCS - @(#)NPPP.java 1.4 -- 09/09/99 - 18:53:17 /
/*
* Copyright (c) 1997 USC Brain Project. email nsl@java.usc.edu.
*/
/* NSLJ Pre-Processor
* based on Guava
* it uses Java to Bison F (JBF).
* This inputs to this file get made by JB.
* The inputs are: jbf/YYtokentypes.java, YYparse.java, YYlex.java
*
* $Log: NPPP.java,v $
* Revision 1.4 1997/11/06 03:21:46 erhan
* NSL3.0.b
*
* Revision 1.3 1997/07/30 21:10:30 erhan
* nsl3.0
*
* Revision 1.2 1997/03/28 02:04:30 aalx
* modified to include copyright notices to us or the appropriate author.
*
* Revision 1.1.1.1 1997/03/12 23:09:23 nsl
* changed dir struct
*
* Revision 1.3 1997/02/27 07:07:34 erhan
* 1
*
* Revision 1.2 1997/02/25 23:37:35 erhan
* ok?
*
* Revision 1.1.1.1 1997/02/20 08:04:35 nsl
* Importing NPPP
*
*/
package lx.src;
import java.io.*;
import pp.src.jbf.*;
import lx.src.util.*;
import lx.src.YYlex;
/** NSLJ Pre-Processor
* based on JBF.
*/
public class NPPP {
public static YYlex yyl = new YYlex(System.in,System.out);
public static YYparse yyp = new YYparse(yyl,System.err);
public static NslPrePreProcessor nppp = new NslPrePreProcessor();
/** Main runtime routine - call java NPPP to run.
*/
public static void main(String argv[])
{
boolean debuglex = false;
boolean debugparse = false;
boolean lexonly = false;
boolean nocomments = false;
YYtoken yylval;
int llevel = 0;
int plevel = 0;
int lineno =1;
System.err.println("NSL pre-pre-processor PHASE 1....");
//print out default preheader
System.out.println("/* This file is generated by NSL3.0 preprocessor*/\n");
// Default import statements now gen using nslImport nslAllImport /*nslImport*/
//System.out.println("verbatim NSLJ"); /*nslImport*/
// System.out.println("\t\t/*$$ Line no: "+lineno+" $$*/");
// lineno++;
// System.out.println(" import nslj.src.system.*;"); /*nslImport*/
// System.out.println("\t\t/*$$ Line no: "+lineno+" $$*/");
// lineno++;
// System.out.println(" import nslj.src.cmd.*;"); /*nslImport*/
// System.out.println("\t\t/*$$ Line no: "+lineno+" $$*/");
// lineno++;
// System.out.println(" import nslj.src.lang.*;"); /*nslImport*/
// System.out.println("\t\t/*$$ Line no: "+lineno+" $$*/");
// lineno++;
// System.out.println(" import nslj.src.math.*;"); /*nslImport*/
// System.out.println("\t\t/*$$ Line no: "+lineno+" $$*/");
// lineno++;
// System.out.println(" import nslj.src.display.*;"); /*nslImport*/
// System.out.println("\t\t/*$$ Line no: "+lineno+" $$*/");
// lineno++;
// System.out.println("verbatim off"); /*nslImport*/
// System.out.println("\t\t/*$$ Line no: "+lineno+" $$*/");
// lineno++;
if (argv.length == 1 &&
(argv[0].compareTo("-0")==0 || argv[0].compareTo("-h")==0)) {
System.out.println("Usage: java NPPP [-nocomments] [-debug][-debuglex][-debugparse][-lex][-l Lexlevel][-p ParseLevel] .java");
}
for(int i=0;i 0) yyl.setdebug(llevel); else yyl.setdebug(true);
}
if(yyp != null && debugparse) {
System.out.println("parse debug turned on");
if(plevel > 0) yyp.setdebug(plevel); else yyp.setdebug(true);
}
try {
/* LEX ONLY *******************************/
if(lexonly) {
do {
yylval = yyl.yylex();
} while (yylval != null);
System.out.println("/* RESIDUE*/ "+yyl.yytext.lexeme());
System.out.println("\n/* FIRST PASS DONE */");
if(debuglex)System.out.println("lex succeeded");
} else {
yyp.yyparse();
//nppp.genCode();
if(debugparse)System.out.println("parse succeeded");
}
} catch (Exception e) {
System.err.println("!!! exception detected:" + e.getMessage());
e.printStackTrace();
System.err.println("*** CAN NOT PARSE MOD FILE ! *** \n");
System.exit(0);
}
}
}; /*class NPPP*/