Commit d11b3714 authored by Johannes Roith's avatar Johannes Roith

Merge branch 'master' of github.com:jroith/cup-eclipse

parents 0c7bfb52 f012dc71
......@@ -3,7 +3,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="/CupParser/bin/jar/CupParser.jar"/>
<classpathentry kind="lib" path="/CupParser/lib/java-cup-11b-runtime.jar"/>
<classpathentry kind="lib" path="/CupParser/bin/jar/CupParser.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -24,5 +24,13 @@
</content-type>
</extension>
<extension
id="CupDocumentSetupParticipant"
point="org.eclipse.core.filebuffers.documentSetup">
<participant
class="de.tum.in.www2.cupplugin.editors.CupDocumentSetupParticipant"
extensions="cup">
</participant>
</extension>
</plugin>
package de.tum.in.www2.cupplugin.editors;
import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
public class CupDocumentSetupParticipant implements IDocumentSetupParticipant {
@Override
public void setup(IDocument document) {
IDocumentPartitioner partitioner = new FastPartitioner(new CupPartionScanner(), CupPartionScanner.PARTITION_TYPES);
partitioner.connect(document);
}
}
package de.tum.in.www2.cupplugin.editors;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.Token;
public class CupPartionScanner extends RuleBasedPartitionScanner {
//public final static String CUP_CODE = "__cup_code";
public final static String JAVA_CODE = "__java_code";
public final static String[] PARTITION_TYPES = new String[] {
IDocument.DEFAULT_CONTENT_TYPE, CupPartionScanner.JAVA_CODE
};
public CupPartionScanner() {
//IToken cupCode = new Token(CupPartionScanner.CUP_CODE);
IToken javaCode = new Token(CupPartionScanner.JAVA_CODE);
List<IRule> rules = new ArrayList<IRule>();
rules.add(new MultiLineRule("{:", ":}", javaCode));
IPredicateRule[] result = new IPredicateRule[rules.size()];
rules.toArray(result);
setPredicateRules(result);
}
}
package de.tum.in.www2.cupplugin.editors;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import java_cup.*;
import java_cup.runtime.ComplexSymbolFactory;
......@@ -8,9 +10,9 @@ import java_cup.runtime.ComplexSymbolFactory;
public class CupTextEditor extends TextEditor {
public CupTextEditor() {
super();
// ComplexSymbolFactory f = new ComplexSymbolFactory();
// java_cup.Lexer = new java_cup.Lexer(arg0, f);
}
}
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