Commit d2c78bdc authored by petter's avatar petter

refactoring

git-svn-id: https://www2.in.tum.de/repos/cup/develop@64 f8377d4f-c7f8-0310-b030-a31f13008fac
parent 2602133b
......@@ -16,8 +16,8 @@
<mkdir dir="${dist}"/>
</target>
<target name="clean">
<delete file="${java}/Parser.java" />
<delete file="${java}/Lexer.java" />
<delete file="${java}/miniparser/Parser.java" />
<delete file="${java}/miniparser/Lexer.java" />
<delete dir="${classes}" />
<delete dir="${dist}" />
</target>
......@@ -36,7 +36,7 @@
<copy todir="${dist}"><fileset dir="${lib}" includes="**/**.jar"/></copy>
<jar jarfile="${dist}/Compiler.jar" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="Main" />
<attribute name="Main-Class" value="miniparser.Main" />
<attribute name="Class-Path" value="java-cup-11b-runtime.jar" />
</manifest>
</jar>
......
package miniparser;
import java.util.*;
import java.io.*;
import java_cup.runtime.Symbol;
......
package miniparser;
import java_cup.runtime.Symbol;
import java_cup.runtime.ComplexSymbolFactory;
import java_cup.runtime.ComplexSymbolFactory.Location;
......
package minijava;
import java.io.InputStream;
import java_cup.runtime.ComplexSymbolFactory;
import minijava.Program;
import miniparser.*;
public class InMemoryParser {
private InputStream in;
public InMemoryParser(InputStream in) {
this.in=in;
}
public Program parse() throws Exception {
Lexer scanner = null;
ComplexSymbolFactory csf = new ComplexSymbolFactory();
scanner = new Lexer( new java.io.InputStreamReader(in),csf );
Parser p = new Parser(scanner, csf);
return (Program)p.parse().value;
}
}
This diff is collapsed.
package miniparser;
import java_cup.runtime.ComplexSymbolFactory;
import java.io.*;
......
This diff is collapsed.
//----------------------------------------------------
// The following code was generated by CUP v0.11b 20150325 (SVN rev 63)
//----------------------------------------------------
package miniparser;
/** CUP generated interface containing symbol constants. */
public interface sym {
/* terminals */
public static final int READ = 11;
public static final int IDENT = 21;
public static final int SEMICOLON = 2;
public static final int ELSE = 9;
public static final int STRINGCONST = 22;
public static final int COMP = 18;
public static final int WHILE = 10;
public static final int END = 7;
public static final int INTCONST = 20;
public static final int BBINOP = 19;
public static final int IF = 8;
public static final int WRITE = 12;
public static final int BEGIN = 6;
public static final int TYPE = 15;
public static final int COMMA = 3;
public static final int EOF = 0;
public static final int error = 1;
public static final int BUNOP = 13;
public static final int ASSIGN = 14;
public static final int RPAR = 5;
public static final int BINOP = 16;
public static final int LPAR = 4;
public static final int BOOLCONST = 23;
public static final int UNOP = 17;
public static final String[] terminalNames = new String[] {
"EOF",
"error",
"SEMICOLON",
"COMMA",
"LPAR",
"RPAR",
"BEGIN",
"END",
"IF",
"ELSE",
"WHILE",
"READ",
"WRITE",
"BUNOP",
"ASSIGN",
"TYPE",
"BINOP",
"UNOP",
"COMP",
"BBINOP",
"INTCONST",
"IDENT",
"STRINGCONST",
"BOOLCONST"
};
}
Markdown is supported
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