Commit bc3256b6 authored by Konrad Pröll's avatar Konrad Pröll
Browse files
parents 7df9c9ab 8325f67d
......@@ -22,8 +22,9 @@ public abstract class CodeBlock extends AbstractNode {
super(range);
this.debugId = debugId;
this.blob = blob;
// this.blob = " public class Parser{" + blob + "}";
try{
this.javaTree = JavaCompiler.parseJava(blob);
this.javaTree = JavaCompiler.parseJava(this.blob);
} catch(Exception e){}
}
......
......@@ -27,37 +27,8 @@ public class JavaCompiler {
// Remove unwanted unary branch chains from the syntax tree
elem = SyntaxTreeTransform.removeUnaryChains(elem);
// Dump DoM into XML-String via output stream
XMLOutputFactory outFactory = XMLOutputFactory.newInstance();
// System.out.println(elem);
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLStreamWriter sw = outFactory.createXMLStreamWriter(out);
XMLElement.dump(null, sw, elem);
//PrintWriter pw = new PrintWriter("debug.xml");
//String s = new String(out.toByteArray());
//pw.print(s);
//pw.flush();
//pw.close();
// Transform XML-Tree via XSL to carry symbolname as tagname
Transformer transformer;
transformer = TransformerFactory.newInstance().newTransformer(new StreamSource("tree.xsl"));
Source text = new StreamSource(new ByteArrayInputStream(out.toByteArray()));
out = new ByteArrayOutputStream();
transformer.transform(text, new StreamResult(out));
// Transform XML-Tree via XSL into an HTML-Based Syntaxtree
transformer= TransformerFactory.newInstance().newTransformer(new StreamSource("tree-view.xsl"));
text=new StreamSource(new ByteArrayInputStream(out.toByteArray()));
//transformer.transform(text,new StreamResult(new File(args[1]+".ast.html")));
System.out.println(" -> Transformation succeeded");
return elem;
}
//TODO add exception
......
//----------------------------------------------------
// The following code was generated by CUP v0.11b 20141202 (SVN rev 60)
//----------------------------------------------------
package de.in.tum.www2.cup.internal;
/** CUP generated interface containing symbol constants. */
public interface sym {
/* terminals */
public static final int WITH = 11;
public static final int CODE_STRING = 35;
public static final int PARSER = 6;
public static final int SEMI = 13;
public static final int INIT = 9;
public static final int STAR = 15;
public static final int SCAN = 10;
public static final int BAR = 19;
public static final int LT = 29;
public static final int COMMA = 14;
public static final int NON = 8;
public static final int CLASS = 33;
public static final int CODE = 4;
public static final int DOT = 16;
public static final int ID = 34;
public static final int LEFT = 21;
public static final int EOF = 0;
public static final int SUPER = 31;
public static final int error = 1;
public static final int START = 12;
public static final int NONTERMINAL = 27;
public static final int ACTION = 5;
public static final int LBRACK = 25;
public static final int IMPORT = 3;
public static final int COLON = 17;
public static final int RBRACK = 26;
public static final int PACKAGE = 2;
public static final int NONASSOC = 23;
public static final int EXTENDS = 32;
public static final int PRECEDENCE = 20;
public static final int QUESTION = 30;
public static final int PERCENT_PREC = 24;
public static final int TERMINAL = 7;
public static final int RIGHT = 22;
public static final int GT = 28;
public static final int COLON_COLON_EQUALS = 18;
public static final String[] terminalNames = new String[] {
"EOF",
"error",
"PACKAGE",
"IMPORT",
"CODE",
"ACTION",
"PARSER",
"TERMINAL",
"NON",
"INIT",
"SCAN",
"WITH",
"START",
"SEMI",
"COMMA",
"STAR",
"DOT",
"COLON",
"COLON_COLON_EQUALS",
"BAR",
"PRECEDENCE",
"LEFT",
"RIGHT",
"NONASSOC",
"PERCENT_PREC",
"LBRACK",
"RBRACK",
"NONTERMINAL",
"GT",
"LT",
"QUESTION",
"SUPER",
"EXTENDS",
"CLASS",
"ID",
"CODE_STRING"
};
}
//----------------------------------------------------
// The following code was generated by CUP v0.11b 20141204 (SVN rev 60)
//----------------------------------------------------
package de.in.tum.www2.cup.internal;
/** CUP generated interface containing symbol constants. */
public interface sym {
/* terminals */
public static final int WITH = 11;
public static final int CODE_STRING = 35;
public static final int PARSER = 6;
public static final int SEMI = 13;
public static final int INIT = 9;
public static final int STAR = 15;
public static final int SCAN = 10;
public static final int BAR = 19;
public static final int LT = 29;
public static final int COMMA = 14;
public static final int NON = 8;
public static final int CLASS = 33;
public static final int CODE = 4;
public static final int DOT = 16;
public static final int ID = 34;
public static final int LEFT = 21;
public static final int EOF = 0;
public static final int SUPER = 31;
public static final int error = 1;
public static final int START = 12;
public static final int NONTERMINAL = 27;
public static final int ACTION = 5;
public static final int LBRACK = 25;
public static final int IMPORT = 3;
public static final int COLON = 17;
public static final int RBRACK = 26;
public static final int PACKAGE = 2;
public static final int NONASSOC = 23;
public static final int EXTENDS = 32;
public static final int PRECEDENCE = 20;
public static final int QUESTION = 30;
public static final int PERCENT_PREC = 24;
public static final int TERMINAL = 7;
public static final int RIGHT = 22;
public static final int GT = 28;
public static final int COLON_COLON_EQUALS = 18;
public static final String[] terminalNames = new String[] {
"EOF",
"error",
"PACKAGE",
"IMPORT",
"CODE",
"ACTION",
"PARSER",
"TERMINAL",
"NON",
"INIT",
"SCAN",
"WITH",
"START",
"SEMI",
"COMMA",
"STAR",
"DOT",
"COLON",
"COLON_COLON_EQUALS",
"BAR",
"PRECEDENCE",
"LEFT",
"RIGHT",
"NONASSOC",
"PERCENT_PREC",
"LBRACK",
"RBRACK",
"NONTERMINAL",
"GT",
"LT",
"QUESTION",
"SUPER",
"EXTENDS",
"CLASS",
"ID",
"CODE_STRING"
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment