<commit_before>import java.util.*;
import java.io.*;

public class Fifth {
    public static final String VERSION = "1";

    public static Fifth instance;

    public static void main(String[] a) throws IOException{
        if(a.length == 1){
            File f = new File(a[0]);
            instance = new Fifth(f);
        } else {
            instance = new Fifth();
        }
    }

    File file;
    Stack stack = new Stack(64 * 1024);

    public Fifth(File f) throws IOException{
        this.file = f;
        FileReader fr = new FileReader(this.file);
        BufferedReader br = new BufferedReader(fr);
        String line;
        while((line = br.readLine()) != null){
            for(char c : line.trim().toCharArray()){
                try{
                    parse(c);
                }catch(Exception e){e.printStackTrace();}
            }
        }
        br.close();
        fr.close();
    }

    public Fifth(){
        Scanner sn = new Scanner(System.in);
        while(true){
            System.out.print("fifth" + VERSION + " >> ");
            for(char c : sn.nextLine().toCharArray()){
                try{
                    parse(c);
                }catch(Exception e){e.printStackTrace();}
            }
        }
    }

    //Variables for parsing
    ArrayList<CodeBlock> codeBlocks = new ArrayList<CodeBlock>();
    boolean codeBlock = false;
    boolean blockCreate = false;
    StringBuilder cb = null;
    StringBuilder sb = null;
    boolean string = false;
    boolean skip = false;
    boolean file = false; // File mode

    public void parse(char c) throws NumberFormatException, IOException{
        if(skip){
            skip = false;
            return;
        }
        for(CodeBlock cb : codeBlocks){
            if(cb.name == c){
                cb.run();
                return;
            }
        }

        if(file){
            file = false;
            if(c == 'i'){
                stack.push(readFile(stack.pop().toString()));
            }
            else if(c == 'o'){
                String path = stack.pop().toString();
                String output = stack.pop().toString();
                writeFile(path, output);
            }
            return;
        }
        
        if(c == '{'){
            cb = new StringBuilder();
            codeBlock = true;
        }
        else if(c == '}'){
            cb = null;
            codeBlock = false;
            blockCreate = true;
        }
        else if(blockCreate){
            codeBlocks.add(new CodeBlock(c, cb.toString()));
            blockCreate = false;
        }
        else if(codeBlock){
            cb.append(c);
        }
        else if(String.valueOf(c).matches("[0-9A-Z]")){
            stack.push(Integer.parseInt(c, 36));
        }
        else if(c == '"'){
            if(string){
                String p = sb.toString();
                sb = null;
                stack.push(p);
            }else{
                sb = new StringBuilder();
                string = true;
            }
        }
        else if(string){
            sb.append(c);
        }

        else if(c == '+'){
            Object b = stack.pop();
            Object a = stack.pop();
            if(a instanceof String || b instanceof String){
                String as = a.toString();
                String bs = b.toString();
                stack.push(as + bs);
            }
            else {
                stack.push(((int)a) + ((int)b));
            }
        }
        else if(c == '-'){
            Object b = stack.pop();
            Object a = stack.pop();
            if(a instanceof String || b instanceof String){
                String as = a.toString();
                String bs = b.toString();
                String c = as.replaceAll(bs, "");
                stack.push(c);
            }
            else {<commit_msg>push single characters<commit_after>import java.util.*;
import java.io.*;

public class Fifth {
    public static final String VERSION = "1";

    public static Fifth instance;

    public static void main(String[] a) throws IOException{
        if(a.length == 1){
            File f = new File(a[0]);
            instance = new Fifth(f);
        } else {
            instance = new Fifth();
        }
    }

    File file;
    Stack stack = new Stack(64 * 1024);

    public Fifth(File f) throws IOException{
        this.file = f;
        FileReader fr = new FileReader(this.file);
        BufferedReader br = new BufferedReader(fr);
        String line;
        while((line = br.readLine()) != null){
            for(char c : line.trim().toCharArray()){
                try{
                    parse(c);
                }catch(Exception e){e.printStackTrace();}
            }
        }
        br.close();
        fr.close();
    }

    public Fifth(){
        Scanner sn = new Scanner(System.in);
        while(true){
            System.out.print("fifth" + VERSION + " >> ");
            for(char c : sn.nextLine().toCharArray()){
                try{
                    parse(c);
                }catch(Exception e){e.printStackTrace();}
            }
        }
    }

    //Variables for parsing
    ArrayList<CodeBlock> codeBlocks = new ArrayList<CodeBlock>();
    boolean codeBlock = false;
    boolean blockCreate = false;
    StringBuilder cb = null;
    StringBuilder sb = null;
    boolean string = false;
    boolean skip = false;
    boolean file = false; // File mode
    boolean character = false;

    public void parse(char c) throws NumberFormatException, IOException{
        if(skip){
            skip = false;
            return;
        }
        for(CodeBlock cb : codeBlocks){
            if(cb.name == c){
                cb.run();
                return;
            }
        }

        if(file){
            file = false;
            if(c == 'i'){
                stack.push(readFile(stack.pop().toString()));
            }
            else if(c == 'o'){
                String path = stack.pop().toString();
                String output = stack.pop().toString();
                writeFile(path, output);
            }
            return;
        }
        
        if(c == '{'){
            cb = new StringBuilder();
            codeBlock = true;
        }
        else if(c == '}'){
            cb = null;
            codeBlock = false;
            blockCreate = true;
        }
        else if(blockCreate){
            codeBlocks.add(new CodeBlock(c, cb.toString()));
            blockCreate = false;
        }
        else if(codeBlock){
            cb.append(c);
        }
        else if(String.valueOf(c).matches("[0-9A-Z]")){
            stack.push(Integer.parseInt(c, 36));
        }
        else if(c == '"'){
            if(string){
                String p = sb.toString();
                sb = null;
                stack.push(p);
            }else{
                sb = new StringBuilder();
                string = true;
            }
        }
        else if(string){
            sb.append(c);
        }
        else if(c == '\''){
            character = true;
        }
        else if(character){
            character = false;
            stack.push(String.valueOf(c));
        }
        else if(c == '+'){
            Object b = stack.pop();
            Object a = stack.pop();
            if(a instanceof String || b instanceof String){
                String as = a.toString();
                String bs = b.toString();
                stack.push(as + bs);
            }
            else {
                stack.push(((int)a) + ((int)b));
            }
        }
        else if(c == '-'){
            Object b = stack.pop();
            Object a = stack.pop();
            if(a instanceof String || b instanceof String){
                String as = a.toString();
                String bs = b.toString();
                String c = as.replaceAll(bs, "");
                stack.push(c);
            }
            else {
{'fraction_non_alphanumeric': 0.12744232950964327, 'fraction_numerical': 0.0032774486322954747, 'mean_word_length': 1.2488662131519275, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '849913', 'n_tokens_mistral': 2153, 'n_tokens_neox': 2071, 'n_words': 516}