Package java2opSem

Examples of java2opSem.ExceptionJava2opSem


    FileReader r;
    try {
      r = new FileReader(fileToConvert);
      r.read(source);
    } catch (FileNotFoundException e) {
      throw new ExceptionJava2opSem("No such file : " + fileToConvert);
    } catch (IOException e) {
      throw new ExceptionJava2opSem("Cannot read file : " + fileToConvert);
    }
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setSource(source);
    parser.setResolveBindings(true);
View Full Code Here


    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);
    }
  }
View Full Code Here

  // ########### Function to start parsing
  public void parse(ArrayList<String> param) throws ExceptionJava2opSem {
    Jml2opSemVisitor v = new Jml2opSemVisitor(param);
    rootJml.accept(v);
    if (v.hasError())
      throw new ExceptionJava2opSem("\nJML specification contains statements that are not yet implemented.");
    else
      jmlSpec = v.getJml();
  }
View Full Code Here

TOP

Related Classes of java2opSem.ExceptionJava2opSem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.