bl791's picture
download
raw
2.55 kB
package mechanique;
/*
MechaniQue, the programming language for Interactive Fiction
Copyright (C) 2007 G.J.G.T. (Gabor) de Mooij
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation (highest version applies !!).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
---MECHANIQUESOFT/GABOR DE MOOIJ
*/
import java.io.*;
import java.util.*;
import java.util.regex.*;
import java.applet.*;
import java.io.Serializable;
import java.lang.Math;
;
public class Parser implements Serializable
{
private String[] targets = new String[5000];
private String[] replacers = new String[5000];
private int i=0;
public Parser()
{
for(int j=0; j<5000; j++) {
this.targets[j]="";
this.replacers[j]="";
}
}
public void addParseRule(String source, String destination)
{
this.targets[this.i] = source;
this.replacers[this.i] = destination;
this.i++;
}
public String parse(String t)
{
t = " "+t+" "; //add extra spaces to facilitate parsing
for(int j=0; j<this.i; j++)
{
/* if ((t.indexOf(" "+this.targets[j]+" ")!=-1 ||
t.indexOf(this.targets[j]+" ")==0 ||
t.indexOf(" "+this.targets[j])==(t.length()-this.targets[j].length()) ) && !this.targets[j].equals(""))
{
t=t.replaceAll(" "+this.targets[j]+" "," "+this.replacers[j]+" ");
t=t.replaceAll(" "+this.targets[j]+"\\$"," "+this.replacers[j]+"");
t=t.replaceAll("\\^"+this.targets[j]+" ",""+this.replacers[j]+" ");
}*/
t=t.replaceAll(" "+this.targets[j]+" "," "+this.replacers[j]+" ");
t=t.replaceAll(" "+this.targets[j]+"\\$"," "+this.replacers[j]+"");
t=t.replaceAll("\\^"+this.targets[j]+" ",""+this.replacers[j]+" ");
}
return t;
}
}

Xet Storage Details

Size:
2.55 kB
·
Xet hash:
988ec577ee83b5fddead796baa7c9ee4a3e562c61fea2760c18dbb0d433072e9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.