X preprocessor tweaks

X   "http://acg.media.mit.edu" doesn't work because of //
X   "color.jpg" -> "int.jpg" causes trouble
X why does this line cause an error?
// String url = "http:\u002f\u002fwww.Proce55ing.net";
X   it's not in the preprocessor, but kopi seems to be having trouble
This commit is contained in:
benfry
2002-11-19 05:43:10 +00:00
parent c98782b051
commit d0ad011dfd
2 changed files with 57 additions and 27 deletions
+40 -15
View File
@@ -185,8 +185,9 @@ public class KjcEngine extends PdeEngine {
// so that regexp works correctly in this strange edge case
if (program.indexOf("color") == 0) program = " " + program;
program = substipoot(program,
"([^A-Za-z0-9_])color([^A-Za-z0-9_\\(])", "$1int$2");
//program = substipoot(program, "([^A-Za-z0-9_])color\\((.*)\\)", "$1(int)($2)");
"([;\\s])color([\\s])", "$1int$2");
//"([^A-Za-z0-9_.])color([^A-Za-z0-9_\\(.])", "$1int$2");
program = substipoot(program, "([^A-Za-z0-9_])color\\((.*)\\)", "$1(int)($2)");
}
if (PdeBase.getBoolean("compiler.inline_web_colors", true)) {
@@ -394,12 +395,18 @@ public class KjcEngine extends PdeEngine {
//static char encodeTable[] = new char[127];
//static char decodeTable[] = new char[127];
static char rotateTable[] = new char[127];
static char rotateTable[] = new char[128];
static {
for (int i = 0; i < 80; i++) {
rotateTable[i+48] = (char) (48 + ((i + 40) % 80));
}
/*
int rot = (123 - 65) / 2;
for (int i = 65; i < 123; i++) {
rotateTable[i] = (char) (((i - 65 + rot) % (rot*2)) + 65); // : (char)i;
}
*/
//for (int i = 33; i < 127; i++) {
//rotateTable[i] = //Character.isAlpha((char)i) ?
@@ -419,9 +426,11 @@ public class KjcEngine extends PdeEngine {
// need to preprocess class to remove comments
// so tthat they don't fool this crappy parsing below
char p[] = program.toCharArray();
char lastp = 0;
boolean insideComment = false;
boolean eolComment = false;
boolean slash = false;
boolean insideQuote = false;
for (int i = 0; i < p.length; i++) {
if (insideComment) {
if (eolComment &&
@@ -438,29 +447,45 @@ public class KjcEngine extends PdeEngine {
} else {
//if ((p[i] > 32) && (p[i] < 127)) {
if ((p[i] >= 0x30) && (p[i] < 127)) {
if ((p[i] >= 48) && (p[i] < 128)) {
p[i] = rotateTable[p[i]];
//p[i] = encode ? encodeTable[p[i]] : decodeTable[p[i]];
}
//p[i] = ' ';
}
} else { // not yet inside a comment
if (p[i] == '/') {
if (slash) {
insideComment = true;
eolComment = true;
if (insideQuote) {
if ((p[i] == '\"') && (lastp != '\\')) {
insideQuote = !insideQuote;
} else {
slash = true;
if ((p[i] >= 48) && (p[i] < 128)) {
p[i] = rotateTable[p[i]];
//p[i] = encode ? encodeTable[p[i]] : decodeTable[p[i]];
}
}
} else if (p[i] == '*') {
if (slash) {
insideComment = true;
eolComment = false;
} else { // not inside a quote
if (p[i] == '/') {
if (slash) {
insideComment = true;
eolComment = true;
} else {
slash = true;
}
} else if (p[i] == '\"') {
if (lastp != '\\') insideQuote = !insideQuote;
} else if (p[i] == '*') {
if (slash) {
insideComment = true;
eolComment = false;
}
} else {
slash = false;
}
} else {
slash = false;
}
}
lastp = p[i];
}
//System.out.println(new String(p));
return new String(p);
+17 -12
View File
@@ -35,6 +35,12 @@ X pmouseX should be set at the end of loop(), not on mouse movement
X allow 3d curves
X curveVertex and bezierVertex that take 3 args
X 3d versions of bezier() and curve()
X preprocessor tweaks
X "http://acg.media.mit.edu" doesn't work because of //
X "color.jpg" -> "int.jpg" causes trouble
X why does this line cause an error?
// String url = "http:\u002f\u002fwww.Proce55ing.net";
X it's not in the preprocessor, but kopi seems to be having trouble
bagel
_ images don't load during setup()
@@ -47,26 +53,22 @@ _ make into oval function
_ font smoothing (unless hint SMOOTH_IMAGES enabled) is broken
pde
_ seems that file i/o may be picking up lots of extra \r
_ perhaps when doing setText, it's goobering things up
_ better default size than 300x300 when starting up first time
_ set frame title of launched window to the name of the sketch
_ when renaming a sketch, select the text in the field,
so you can type the new name immediately.
_ use date in the sketch name sketch_021104
_ with a _2 if needed or '021104a' '021104b' etc
_ when using save as, allow to remove the old (numbered) sketch
_ preprocessor problems
_ "color.jpg" or "int.jpg" causes trouble
_ "http://acg.media.mit.edu" doesn't work because of //
_ subst Image -> BImage, Font -> BFont
_ remove .class files on save as [dimitre]
When I am working in a project and I save it with another name,
all the old files are copyied to new directory, and some of the old
unused .class files and images remains inside new project JAR files.
_ seems that file i/o may be picking up lots of extra \r
_ perhaps when doing setText, it's goobering things up
_ use date in the sketch name sketch_021104
_ with a _2 if needed or '021104a' '021104b' etc
_ when using save as, allow to remove the old (numbered) sketch
_ get syntax coloring debugged?
_ preprocessor problems -> switch to java cup (one day's work)
_ subst Image -> BImage, Font -> BFont
_ serial port
_ better message for PortInUseException (full explanation)
_ better message for when serial port code not available/not installed
@@ -78,7 +80,10 @@ _ split KjcEngine into three parts
_ how to communicate with other applet/jre when it's been launched
_ support 'classes' folder, through the use of a classloader
_ all .jar files etc are added from this folder automatically
_ talk to casey about better default colors
_ get syntax coloring debugged?
_ talk to casey about better default colors
windows
_ windows 95/98/ME seems to be broken