jdf
2010-10-05 20:37:05 +00:00
parent c8800fea98
commit 64b1439d79
5 changed files with 64 additions and 3 deletions
+18 -2
View File
@@ -257,11 +257,27 @@ public class PdeEmitter implements PdeTokenTypes {
print(thenPath);
// optional "else" clause: an SLIST or an EXPR
// what could be simpler?
final AST elsePath = thenPath.getNextSibling();
if (elsePath != null) {
out.print("else");
dumpHiddenBefore(getBestPrintableNode(elsePath, true));
print(elsePath);
final AST bestPrintableNode = getBestPrintableNode(elsePath, true);
dumpHiddenBefore(bestPrintableNode);
final CommonHiddenStreamToken hiddenBefore =
((CommonASTWithHiddenTokens) elsePath).getHiddenBefore();
if (elsePath.getType() == PdeTokenTypes.SLIST && elsePath.getNumberOfChildren() == 0 &&
hiddenBefore == null) {
out.print("{");
final CommonHiddenStreamToken hiddenAfter =
((CommonASTWithHiddenTokens) elsePath).getHiddenAfter();
if (hiddenAfter == null) {
out.print("}");
} else {
dumpHiddenTokens(hiddenAfter);
}
} else {
print(elsePath);
}
}
}
@@ -430,7 +430,7 @@ public class PdePreprocessor implements PdeTokenTypes {
// Because the meanings of < and > are overloaded to support
// type arguments and type parameters, we have to treat them
// as copyable to hidden text (or else the following syntax,
// such as (); and what not gets lost under certain circumstances
// such as (); and what not gets lost under certain circumstances)
// -- jdf
filter.copy(PdeRecognizer.LT);
filter.copy(PdeRecognizer.GT);
+32
View File
@@ -0,0 +1,32 @@
import processing.core.*;
import processing.xml.*;
import java.applet.*;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.Image;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.util.regex.*;
public class bug400g extends PApplet {
////
public void setup(){
size(100,100);
if(true){
}
else{ // Syntax error on token "else", } expected
}
}
static public void main(String args[]) {
PApplet.main(new String[] { "--bgcolor=null", "bug400g" });
}
}
+9
View File
@@ -0,0 +1,9 @@
////
void setup(){
size(100,100);
if(true){
}
else{ // Syntax error on token "else", } expected
}
}
@@ -275,4 +275,8 @@ public class ParserTests {
expectGood("bug315g");
}
@Test
public void bug400g() {
expectGood("bug400g");
}
}