<commit_before>// =========================================================================== //
//                                                                             //
// Copyright 2008-2011 <NAME>, <NAME>, <NAME>,                    //
//   <NAME>, <NAME>, <NAME>, <NAME>,   //
//   <NAME>, <NAME>, <NAME>, <NAME>,        //
//   <NAME>, <NAME> and McGill University.                    //
//                                                                             //
//   Licensed under the Apache License, Version 2.0 (the "License");           //
//   you may not use this file except in compliance with the License.          //
//   You may obtain a copy of the License at                                   //
//                                                                             //
//       http://www.apache.org/licenses/LICENSE-2.0                            //
//                                                                             //
//   Unless required by applicable law or agreed to in writing, software       //
//   distributed under the License is distributed on an "AS IS" BASIS,         //
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  //
//   See the License for the specific language governing permissions and       //
//   limitations under the License.                                            //
//                                                                             //
// =========================================================================== //

package natlab;

import natlab.options.Options;
//import natlab.toolkits.analysis.ForVisitor;
import ast.*;
import natlab.server.*;
import natlab.toolkits.DependenceAnalysis.DependenceAnalysisDriver;
import natlab.toolkits.DependenceAnalysis.HeuristicEngineDriver;
import natlab.toolkits.DependenceAnalysis.McFlatDriver;
import natlab.toolkits.DependenceAnalysis.Profiler;
import natlab.toolkits.analysis.ForVisitor;

import natlab.toolkits.analysis.varorfun.*;
import natlab.toolkits.analysis.defassigned.DefinitelyAssignedAnalysis;
import natlab.toolkits.analysis.example.*;
import natlab.toolkits.analysis.test.*;
import natlab.toolkits.analysis.handlepropagation.*;
import natlab.toolkits.analysis.callgraph.*;
import natlab.example.*;
import natlab.toolkits.rewrite.multireturn.*;
import natlab.toolkits.rewrite.threeaddress.*;
import natlab.toolkits.scalar.AbstractFlowAnalysis;
import natlab.toolkits.analysis.isscalar.*;
import natlab.toolkits.analysis.liveliness.LivelinessAnalysis;
import natlab.refactoring.*;

import natlab.toolkits.rewrite.Validator;


import natlab.toolkits.filehandling.*;

/*import matlab.MatlabParser;
import matlab.TranslationProblem;
import matlab.OffsetTracker;
import matlab.TextPosition;*/
import matlab.*;
import matlab.MatlabParser.program_return;


import java.io.*;
import java.net.*;
import java.util.*;
import java.util.List;
import java.util.prefs.Preferences;

import natlab.toolkits.DependenceAnalysis.ProfilerDriver;
 


/**
 * Main entry point for McLab compiler. Includes a main method that
 * deals with command line options and performs the desired
 * functions. Also includes static methods used to simplify tasks such
 * as parsing program code and translating from matlab to natlab.
 */
public class Main
{
    private static Options options;
    private static final int SERVER_PORT = 47146; //default server port
    private static final long HEART_RATE = 4000; //in milliseconds
    private static final long HEART_DELAY = 5000; //delay till first heart beat check is made
    
    
    /**
     * Main method deals with command line options and execution of
     * desired functions.
     */
    public static void main(String[] args) throws Exception
    {	

     // natlab.toolkits.analysis.functionhandle.TestAnalysis.main(args);
       // System.exit(0);

        //natlab.toolkits.analysis.functionhandle.TestAnalysis.main(args);
        //System.exit(0);

        boolean quiet; //controls the suppression of messages
        ArrayList errors = new ArrayList();
        options = new Options();
        
        if( processCmdLine( args ) ){
            
            if( options.help() ){
                System.err.println(options.getUsage());
            }
            else{
                quiet = options.quiet();  //check if quiet mode is active
                
                if( options.e() ){
                    if( !quiet )
                        System.err.println("exhaustive list");
                }
                if( options.d() ){
                    if( !quiet )
                        System.err.println("dynamic linking");
                }
		
                //fortran neither uses the below parser, nor is a server
                if( options.fortran() ){ //begin fortran
                    //if( options.getFiles().size() == 0 ){
                    //    System.err.println("No files provided, must have at least one file.");
                    //    System.exit(1);
                    //}
                    //System.out.println("compiling to fortran "+options.getFiles());
                    //String[] fargs = {"-d",(String)options.getFiles().get(0)};
                    //System.out.println("calling McFor with "+fargs);
                    natlab.tame.mc4.Mc4.main(args);
                    return;
                } //end fortran
                
                //setting and getting of preferences
                if (options.pref()){
                    NatlabPreferences.modify(options);
                    return;
                }
                
                if( options.server() ){
                    //in server mode
                    if( !quiet )
                        System.err.println("server mode");
                    
                    //setup port number
                    int portNumber = SERVER_PORT;
                    if( options.sp().length() > 0 )
                        portNumber = Integer.parseInt(options.sp());
                    
                    if( !quiet )
                        System.err.println("opening server on port " + portNumber );
                    //start the server
                    ServerSocket serverSocket = null;
                    try{
                        serverSocket = new ServerSocket( portNumber );
                    }
                    catch( IOException e ){
                        System.err.println("Server could not be opened on port "+portNumber);
                        System.exit(1);
                    }
                    if( !quiet )
                        System.err.println("Server started");
                    
                    //wait for and accept a connection
                    Socket clientSocket = null;<commit_msg>update main<commit_after>// =========================================================================== //
//                                                                             //
// Copyright 2008-2011 <NAME>, <NAME>, <NAME>,                    //
//   <NAME>, <NAME>, <NAME>, <NAME>,   //
//   <NAME>, <NAME>, <NAME>, <NAME>,        //
//   <NAME>, <NAME> and McGill University.                    //
//                                                                             //
//   Licensed under the Apache License, Version 2.0 (the "License");           //
//   you may not use this file except in compliance with the License.          //
//   You may obtain a copy of the License at                                   //
//                                                                             //
//       http://www.apache.org/licenses/LICENSE-2.0                            //
//                                                                             //
//   Unless required by applicable law or agreed to in writing, software       //
//   distributed under the License is distributed on an "AS IS" BASIS,         //
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  //
//   See the License for the specific language governing permissions and       //
//   limitations under the License.                                            //
//                                                                             //
// =========================================================================== //

package natlab;

import natlab.options.Options;
//import natlab.toolkits.analysis.ForVisitor;
import ast.*;
import natlab.server.*;
import natlab.toolkits.DependenceAnalysis.DependenceAnalysisDriver;
import natlab.toolkits.DependenceAnalysis.HeuristicEngineDriver;
import natlab.toolkits.DependenceAnalysis.McFlatDriver;
import natlab.toolkits.DependenceAnalysis.Profiler;
import natlab.toolkits.analysis.ForVisitor;

import natlab.toolkits.analysis.varorfun.*;
import natlab.toolkits.analysis.defassigned.DefinitelyAssignedAnalysis;
import natlab.toolkits.analysis.example.*;
import natlab.toolkits.analysis.test.*;
import natlab.toolkits.analysis.handlepropagation.*;
import natlab.toolkits.analysis.callgraph.*;
import natlab.example.*;
import natlab.toolkits.rewrite.multireturn.*;
import natlab.toolkits.rewrite.threeaddress.*;
import natlab.toolkits.scalar.AbstractFlowAnalysis;
import natlab.toolkits.analysis.isscalar.*;
import natlab.toolkits.analysis.liveliness.LivelinessAnalysis;
import natlab.refactoring.*;

import natlab.toolkits.rewrite.Validator;


import natlab.toolkits.filehandling.*;

/*import matlab.MatlabParser;
import matlab.TranslationProblem;
import matlab.OffsetTracker;
import matlab.TextPosition;*/
import matlab.*;
import matlab.MatlabParser.program_return;


import java.io.*;
import java.net.*;
import java.util.*;
import java.util.List;
import java.util.prefs.Preferences;

import natlab.toolkits.DependenceAnalysis.ProfilerDriver;
 


/**
 * Main entry point for McLab compiler. Includes a main method that
 * deals with command line options and performs the desired
 * functions. Also includes static methods used to simplify tasks such
 * as parsing program code and translating from matlab to natlab.
 */
public class Main
{
    private static Options options;
    private static final int SERVER_PORT = 47146; //default server port
    private static final long HEART_RATE = 4000; //in milliseconds
    private static final long HEART_DELAY = 5000; //delay till first heart beat check is made
    
    
    /**
     * Main method deals with command line options and execution of
     * desired functions.
     */
    public static void main(String[] args) throws Exception
    {	

     // natlab.toolkits.analysis.functionhandle.TestAnalysis.main(args);
       // System.exit(0);

        //natlab.toolkits.analysis.functionhandle.TestAnalysis.main(args);
        //System.exit(0);

        boolean quiet; //controls the suppression of messages
        ArrayList errors = new ArrayList();
        options = new Options();
        
        if( processCmdLine( args ) ){
            
            if( options.help() ){
                System.err.println(options.getUsage());
            }
            else{
                quiet = options.quiet();  //check if quiet mode is active
                
                if( options.e() ){
                    if( !quiet )
                        System.err.println("exhaustive list");
                }
                if( options.d() ){
                    if( !quiet )
                        System.err.println("dynamic linking");
                }
		
                //fortran neither uses the below parser, nor is a server
                if( options.fortran() ){ //begin fortran
                    //if( options.getFiles().size() == 0 ){
                    //    System.err.println("No files provided, must have at least one file.");
                    //    System.exit(1);
                    //}
                    //System.out.println("compiling to fortran "+options.getFiles());
                    //String[] fargs = {"-d",(String)options.getFiles().get(0)};
                    //System.out.println("calling McFor with "+fargs);
                    natlab.tame.mc4.Mc4.main(args);
                    return;
                } //end fortran
                
                
                
                //setting and getting of preferences
                if (options.pref()){
                    NatlabPreferences.modify(options);
                    return;
                }
                
                if (options.show_pref()){
                	System.out.println("preferences:");
                	Map<String,Object> prefs = NatlabPreferences.getAllPreferences();
                	for (String key : prefs.keySet()){
                		System.out.println(key+"="+prefs.get(key));
                	}
                }
                
                if( options.server() ){
                    //in server mode
                    if( !quiet )
                        System.err.println("server mode");
                    
                    //setup port number
                    int portNumber = SERVER_PORT;
                    if( options.sp().length() > 0 )
                        portNumber = Integer.parseInt(options.sp());
                    
                    if( !quiet )
                        System.err.println("opening server on port " + portNumber );
                    //start the server
                    ServerSocket serverSocket = null;
                    try{
                        serverSocket = new ServerSocket( portNumber );
                    }
                    catch( IOException e ){
                        System.err.println("Server could not be opened on port "+portNumber);
                        System.exit(1);
                    }
                    if( !quiet )
                        System.err.println("Server started");
                    
                    //wait for and accept a connection
                    Socket clientSocket = null;
{'fraction_non_alphanumeric': 0.11769759450171821, 'fraction_numerical': 0.004868270332187858, 'mean_word_length': 1.4671494171670787, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '394416', 'n_tokens_mistral': 3364, 'n_tokens_neox': 3143, 'n_words': 865}