Commit a93cb319 authored by Benedikt Engeser's avatar Benedikt Engeser

Fehlerhaft

parent 010a7681
......@@ -6,23 +6,26 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.eclipse.core.resources.IWorkspace;
import de.tum.in.www2.cupplugin.debug.BreakpointMapper;
import de.tum.in.www2.cupplugin.debug.Debugger;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
public class DebugListener implements IResourceChangeListener {
public void resourceChanged(IResourceChangeEvent event) {
public class DebugListener implements IResourceChangeListener {
public void resourceChanged(IResourceChangeEvent event) {
System.out.println("GOT EVENT: " + event.getType());
if (event.getType() != IResourceChangeEvent.POST_BUILD)
return;
System.out.println("GOT POST BUILD EVENT!");
}
System.out.println("GOT EVENT: " + event.getType());
Debugger.getBreakpointMapper().remap();
if (event.getType() != IResourceChangeEvent.POST_BUILD)
return;
System.out.println("GOT POST BUILD EVENT!");
}
}
// The plug-in ID
......@@ -30,7 +33,7 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
......@@ -41,7 +44,10 @@ public class Activator extends AbstractUIPlugin {
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
......@@ -50,7 +56,10 @@ public class Activator extends AbstractUIPlugin {
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
......@@ -67,10 +76,11 @@ public class Activator extends AbstractUIPlugin {
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
* Returns an image descriptor for the image file at the given plug-in
* relative path
*
* @param path the path
* @param path
* the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
......
......@@ -20,12 +20,17 @@ import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
import org.eclipse.jdt.debug.core.JDIDebugModel;
import de.in.tum.www2.cup.analysis.GetDebuggerMappingVisitor.Mapping;
import de.in.tum.www2.cup.ast.ParserResult;
import de.tum.in.www2.cupplugin.GeneratedFileLocator;
import de.tum.in.www2.cupplugin.PluginUtility;
public class BreakpointMapper {
private Map<CupLineBreakpoint, IBreakpoint> mappings = new HashMap<CupLineBreakpoint, IBreakpoint>();
private Set<CupLineBreakpoint> breakpoints = new HashSet<CupLineBreakpoint>();
private GeneratedFileLocator locator = new GeneratedFileLocator();
public IBreakpoint getRemoteBreakpoint(CupLineBreakpoint breakpoint) {
return mappings.get(breakpoint);
}
......@@ -47,8 +52,13 @@ public class BreakpointMapper {
if(originResource == null){
return;
}
IFile resource = PluginUtility.findGenerated(((IFile) origin
.getResource()));
ParserResult astModel = Debugger.getInstance(originResource).getParserResult();
if(astModel == null){
return;
}
IFile resource = locator.find((IFile) originResource, astModel);
if(resource == null){
return;
}
......
......@@ -93,7 +93,7 @@ public class Debugger {
}
current = null;
}
Debugger tmp = new Debugger(new CupTextEditor());
Debugger tmp = new Debugger(new CupTextEditor());// TODO: lösen
delayedInstances.put(resource, tmp);
return tmp;
......@@ -150,11 +150,9 @@ public class Debugger {
* @return the class name
*/
public String getGeneratedTargetClass(CupLineBreakpoint breakpoint) {
Model m = Model.getInstanceForDocument(myEditor.getDocumentProvider()
.getDocument(myEditor.getEditorInput()));
try {
String rname = m.getAstModel().className.getName().name;
String rname = getParserResult().className.getName().name;
if (!rname.trim().equals("")) {
return rname;
}
......@@ -166,9 +164,7 @@ public class Debugger {
}
public Mapping getDebugId(int lineNumber) {
Model m = Model.getInstanceForDocument(myEditor.getDocumentProvider()
.getDocument(myEditor.getEditorInput()));
ParserResult astModel = m.getAstModel();
ParserResult astModel = getParserResult();
if (astModel == null) {
return null;
......@@ -185,4 +181,13 @@ public class Debugger {
}
public ParserResult getParserResult(){
if(myEditor == null){
System.out.println("myEditor: NULL");
}
Model m = Model.getInstanceForDocument(myEditor.getDocument());
ParserResult astModel = m.getAstModel();
return astModel;
}
}
\ No newline at end of file
......@@ -238,6 +238,9 @@ public class CupJavaProjectWizard extends Wizard implements INewWizard {
*/
IContainer srcDir = (IContainer) project.findMember(new Path("src"));
IFolder cupDir = createDirectory(srcDir, monitor, "cup");
IFolder exampleDir = createDirectory(cupDir, monitor, "example");
IFile parserFile = createFile(project, monitor, "parser.cup",
getTemplate("parser.cup"));
......@@ -245,7 +248,7 @@ public class CupJavaProjectWizard extends Wizard implements INewWizard {
createFile(project, monitor, "input.txt", getTemplate("input.txt"));
createFile(project, monitor, "build.xml", getTemplate("build.xml"));
createFile(srcDir, monitor, "Driver.java", getTemplate("Driver.java"));
createFile(exampleDir, monitor, "Driver.java", getTemplate("Driver.java"));
IFolder folder = createDirectory(project, monitor, "tools");
......
package cup.example;
class Driver {
public static void main(String[] args) throws Exception {
......
......@@ -11,16 +11,17 @@
<taskdef name="cup" classname="java_cup.anttask.CUPTask" classpath="${tools}/java-cup-11b.jar" />
<target name="generate">
<jflex file="lexer.jflex" destdir="${java}" />
<cup srcfile="${base}/parser.cup" destdir="${java}"
parser="Parser"
interface="true"
locations="true"
debugsymbols="true" />
<jflex file="lexer.jflex" destdir="${java}" />
</target>
<path id="libraries">
<files includes="${lib}/java-cup-11b-runtime.jar" />
<files includes="${tools}/java-cup-11b-runtime.jar" />
</path>
<target name="compile" depends="generate">
......
package de.in.tum.www2.cup.internal;
package cup.example;
import java_cup.runtime.ComplexSymbolFactory;
import java_cup.runtime.ComplexSymbolFactory.Location;
import java_cup.runtime.Symbol;
import de.in.tum.www2.cup.Position;
import de.in.tum.www2.cup.ErrorManager;
import de.in.tum.www2.cup.ErrorSource;
import java.lang.Error;
import java.io.InputStreamReader;
......@@ -19,7 +16,7 @@ import java.io.InputStreamReader;
%cup
%char
%{
private ErrorManager errMan;
public Lexer(ComplexSymbolFactory sf, java.io.InputStream is){
this(is);
......@@ -47,12 +44,12 @@ import java.io.InputStreamReader;
}
protected void emit_warning(String message){
System.out.println("scanner warning: " + message + " at : 2 +
System.out.println("scanner warning: " + message + " at : 2 "+
(yyline+1) + " " + (yycolumn+1) + " " + yychar);
}
protected void emit_error(String message){
System.out.println("scanner error: " + message + " at : 2 +
System.out.println("scanner error: " + message + " at : 2" +
(yyline+1) + " " + (yycolumn+1) + " " + yychar);
}
%}
......@@ -84,10 +81,7 @@ ident = ([:jletter:] | "_" ) ([:jletterdigit:] | [:jletter:] | "_" )*
"other" { return symbol("OTHERTERMINAL",OTHERTERMINAL); }
}
<CODESEG> {
":}" { yybegin(YYINITIAL); return symbolFactory.newSymbol("CODE_STRING",CODE_STRING, new Location(csline, cscolumn),new Location(yyline+1,yycolumn+1+yylength()), sb.toString()); }
.|\n { sb.append(yytext()); }
}
// error fallback
.|\n { emit_warning("Unrecognized character '" +yytext()+"' -- ignored"); }
package cup.example;
import java_cup.runtime.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
parser code {:
:}
init with {: :}
scan with {: :}
/* override error routines */
protected Lexer lexer;
:};
init with {:
ComplexSymbolFactory f = new ComplexSymbolFactory();
symbolFactory = f;
File file = new File("input.txt");
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
}catch (IOException e) {
e.printStackTrace();
}
lexer = new Lexer(f,fis);
:};
scan with {: return lexer.next_token(); :};
terminal MYTERMINAL, OTHERTERMINAL;
non terminal Integer expr;
......
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