Commit 86c008d2 authored by Johannes Roith's avatar Johannes Roith

- Add javacup runtime library to newly created project.

- Run parser in example project.
parent d0e782b8
package de.tum.in.www2.cupplugin.controller;
import java.util.EnumSet;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
public interface RegisterForControllerChanges {
EnumSet<JobsToDo> getRequiredJobs();
}
......@@ -35,7 +35,10 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ISetSelectionTarget;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne;
import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageTwo;
......@@ -83,20 +86,11 @@ public class CupJavaProjectWizard extends Wizard implements INewWizard {
@Override
public boolean performFinish() {
IJavaProject jp = secondPage.getJavaProject();
IProject project = jp.getProject();
/*
* IWorkingSet[] workingSets = fFirstPage.getWorkingSets(); if
* (workingSets.length > 0) {
* PlatformUI.getWorkbench().getWorkingSetManager
* ().addToWorkingSets(project, workingSets); }
*/
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException {
try {
doFinish(project, monitor);
doFinish(jp, monitor);
} finally {
monitor.done();
}
......@@ -219,10 +213,12 @@ public class CupJavaProjectWizard extends Wizard implements INewWizard {
return true;
}
private void doFinish(IProject project, IProgressMonitor monitor) {
private void doFinish(IJavaProject jp, IProgressMonitor monitor) {
monitor.beginTask("Creating project ...", 2);
IProject project = jp.getProject();
try {
project.open(monitor);
} catch (CoreException e1) {
......@@ -253,11 +249,31 @@ public class CupJavaProjectWizard extends Wizard implements INewWizard {
IFolder folder = createDirectory(project, monitor, "tools");
createFile(folder, monitor, "JFlex.jar", getTemplate("JFlex.jar"));
createFile(folder, monitor, "java-cup-11b-runtime.jar",
IFile runtimeFile = createFile(folder, monitor, "java-cup-11b-runtime.jar",
getTemplate("java-cup-11b-runtime.jar"));
createFile(folder, monitor, "java-cup-11b.jar",
getTemplate("java-cup-11b.jar"));
IClasspathEntry[] oldClassPath = null;
try {
oldClassPath = jp.getRawClasspath();
} catch (JavaModelException e2) {
e2.printStackTrace();
}
if (oldClassPath != null) {
IClasspathEntry[] newClassPath = new IClasspathEntry[oldClassPath.length + 1];
for (int i = 0; i < oldClassPath.length; i++)
newClassPath[i] = oldClassPath[i];
newClassPath[oldClassPath.length] = JavaCore.newLibraryEntry(runtimeFile.getFullPath(), null, null);
try {
jp.setRawClasspath(newClassPath, monitor);
} catch (JavaModelException e1) {
e1.printStackTrace();
}
}
setBuilder(project);
monitor.worked(1);
......
package cup.example;
import java_cup.runtime.*;
class Driver {
public static void main(String[] args) throws Exception {
System.out.println("Hello from Driver!");
Parser parser = new Parser();
parser.parse();
}
}
\ No newline at end of file
my input file.
\ No newline at end of file
my
\ No newline at end of file
......@@ -26,4 +26,6 @@ terminal MYTERMINAL, OTHERTERMINAL;
non terminal Integer expr;
expr ::= MYTERMINAL {:
// action code here
System.out.println("hello myterminal!");
:} | OTHERTERMINAL;
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