Main compiler = new Main( new CModifier( Constants.ACCESS_FLAG_ARRAY,Constants.ACCESS_FLAG_NAMES ) );
Reader r = null;
try {
r = new FileReader(file);
} catch (FileNotFoundException e) {
throw new ExceptionJava2opSem("Cannot read " + file + ".");
}
parsingController = new ParsingController( r, null );
lexingController = new TokenStreamSelector();
boolean allowUniverses = true;
jmlLexer = new JmlLexer( parsingController, lexingController,
true, true, allowUniverses, compiler );
docLexer = new JavadocLexer( parsingController );
jmlMLLexer = new JmlMLLexer( parsingController, lexingController,
true, true, allowUniverses, compiler );
jmlSLLexer = new JmlSLLexer( parsingController, lexingController,
true, true, allowUniverses, compiler );
try {
lexingController.addInputStream( jmlLexer, "jmlTop" );
lexingController.addInputStream( jmlMLLexer, "jmlML" );
lexingController.addInputStream( jmlSLLexer, "jmlSL" );
lexingController.addInputStream( docLexer, "javadoc" );
lexingController.select( "jmlTop" );
parsingController.addInputStream( lexingController, "jml" );
parsingController.addInputStream( docLexer, "javadoc" );
parsingController.selectInitial( "jml" );
final boolean ACCEPT_MULTIJAVA = true;
final boolean ACCEPT_RELAXEDMULTIJAVA = false;
parser =
new JmlParser(compiler,
parsingController.initialOutputStream(),
parsingController,
false,
ACCEPT_MULTIJAVA,
ACCEPT_RELAXEDMULTIJAVA,
allowUniverses );
rootJml = (JmlCompilationUnit) parser.jCompilationUnit();
//TODO: parser.jAssertStatement(); // fait avancer à la fin du fichier
} catch (Exception e) {
String message = "It was impossible to build the AST for file " + file + "\n";
message+="Possible errors in the program: \n";
message+=" - only integers and arrays of integers are allowed\n";
message+=" - in \"if statements\", then and else blocks must be enclosed with {}\n";
message+=" - \"for loops\" are not allowed (use \"while loops\" instead)\n";
message+=" - JavaDoc comments are not allowed\n";
message+=" - i++ or i-- are not permitted\n";
message+="Possible error in JML specification: \n";
message+=" - requires clause must precede ensures clause\n";
message+=" - clauses must terminate with \";\"\n";
message+=" see http://www.cs.ucf.edu/~leavens/JML/ for JML syntax";
throw new ExceptionJava2opSem(message);
}
}