Skip to content

Commit

Permalink
fixed #59; fixed #87; fixed #89; fixed bug in CommandCollection preve…
Browse files Browse the repository at this point in the history
…nting it from processing some commands (e.g. safeZoneY)
  • Loading branch information
Krzmbrzl committed Aug 7, 2016
1 parent 7a66a0c commit 3a13604
Show file tree
Hide file tree
Showing 92 changed files with 2,629 additions and 577 deletions.
3 changes: 2 additions & 1 deletion plugin/Raven.SQDev.Editors/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Export-Package: org.antlr.v4.runtime;
org.eclipse.swt.custom,
org.antlr.v4.runtime.tree,
raven.sqdev.interfaces,
org.eclipse.jface.text.rules"
org.eclipse.jface.text.rules",
raven.sqdev.editors.parser.preprocessor
Bundle-Vendor: Raven
Import-Package: raven.sqdev.preferences.util
Bundle-ClassPath: ANTLR/antlr-runtime-4.5.3.jar,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
IF=1
IFN=2
ELSE=3
ENDIF=4
DEFINE=5
UNDEFINE=6
INCLUDE=7
UNKNOWN=8
NUMBER=9
STRING=10
ID=11
ESC_LINEBREAK=12
LINEBREAK=13
WS=14
COMMENT=15
ANY=16
'#ifdef'=1
'#ifndef'=2
'#else'=3
'#endif'=4
'#define'=5
'#undef'=6
'#include'=7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
IF=1
IFN=2
ELSE=3
ENDIF=4
DEFINE=5
UNDEFINE=6
INCLUDE=7
UNKNOWN=8
NUMBER=9
STRING=10
ID=11
ESC_LINEBREAK=12
LINEBREAK=13
WS=14
COMMENT=15
ANY=16
'#ifdef'=1
'#ifndef'=2
'#else'=3
'#endif'=4
'#define'=5
'#undef'=6
'#include'=7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,20 @@ public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int
int length = (offendingToken.getType() == Token.EOF) ? 0
: offendingToken.getText().length();

editor.createMarker(IMarker.PROBLEM, offendingToken.getStartIndex(), length, msg,
IMarker.SEVERITY_ERROR);
reportError(offendingToken.getStartIndex(), length, msg);
}

/**
* Reports an error to the respective editor
*
* @param offset
* The offset of the error start
* @param length
* The length of the error
* @param msg
* The error message
*/
public void reportError(int offset, int length, String msg) {
editor.createMarker(IMarker.PROBLEM, offset, length, msg, IMarker.SEVERITY_ERROR);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package raven.sqdev.editors;

/**
* An interface describing a class that provides macro-support
*
* @author Raven
*
*/
public interface IMacroSupport {

/**
* Adds a macro to this <code>IMacroSupport</code>
*
* @param macro
* The <code>Macro</code> to add
*/
public void addMacro(Macro macro);

/**
* Removes the given macro
*
* @param macro
* The <code>Macro</code> to remove
*/
public void removeMacro(Macro macro);
}
54 changes: 54 additions & 0 deletions plugin/Raven.SQDev.Editors/src/raven/sqdev/editors/Macro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package raven.sqdev.editors;

import raven.sqdev.infoCollection.base.Keyword;

/**
* A class representing a defined macro expression
*
* @author Raven
*
*/
public class Macro extends Keyword {

protected int arguments;

/**
* Creates a new macro that has no arguments
*
* @param name
* The name of the macro
*/
public Macro(String name) {
super(name);
arguments = 0;
}

/**
* Creates a new macro
*
* @param name
* The name of the macro
* @param arguments
* The number of arguments this macro can take
*/
public Macro(String name, int arguments) {
super(name);

this.arguments = arguments;
}

/**
* Gets the number of arguments this macro takes
*/
public int getArgumentCount() {
return arguments;
}

/**
* Checks whether this macro uses any arguments
*/
public boolean hasArguments() {
return getArgumentCount() != 0;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
IF=1
IFN=2
ELSE=3
ENDIF=4
DEFINE=5
UNDEFINE=6
INCLUDE=7
UNKNOWN=8
NUMBER=9
STRING=10
ID=11
ESC_LINEBREAK=12
LINEBREAK=13
WS=14
COMMENT=15
ANY=16
'#ifdef'=1
'#ifndef'=2
'#else'=3
'#endif'=4
'#define'=5
'#undef'=6
'#include'=7
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Generated from Preprocessor.g4 by ANTLR 4.5.3
package raven.sqdev.editors.parser.preprocessor;

import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.TerminalNode;

/**
* This class provides an empty implementation of {@link PreprocessorListener},
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
public class PreprocessorBaseListener implements PreprocessorListener {
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterStart(PreprocessorParser.StartContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitStart(PreprocessorParser.StartContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterPreprocessing(PreprocessorParser.PreprocessingContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitPreprocessing(PreprocessorParser.PreprocessingContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterIfBlock(PreprocessorParser.IfBlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIfBlock(PreprocessorParser.IfBlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDefine(PreprocessorParser.DefineContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDefine(PreprocessorParser.DefineContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterUndefine(PreprocessorParser.UndefineContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitUndefine(PreprocessorParser.UndefineContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterInclude(PreprocessorParser.IncludeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitInclude(PreprocessorParser.IncludeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterError(PreprocessorParser.ErrorContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitError(PreprocessorParser.ErrorContext ctx) { }

/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitTerminal(TerminalNode node) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitErrorNode(ErrorNode node) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Generated from Preprocessor.g4 by ANTLR 4.5.3
package raven.sqdev.editors.parser.preprocessor;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;

/**
* This class provides an empty implementation of {@link PreprocessorVisitor},
* which can be extended to create a visitor which only needs to handle a subset
* of the available methods.
*
* @param <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
public class PreprocessorBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements PreprocessorVisitor<T> {
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitStart(PreprocessorParser.StartContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitPreprocessing(PreprocessorParser.PreprocessingContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIfBlock(PreprocessorParser.IfBlockContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDefine(PreprocessorParser.DefineContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitUndefine(PreprocessorParser.UndefineContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInclude(PreprocessorParser.IncludeContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitError(PreprocessorParser.ErrorContext ctx) { return visitChildren(ctx); }
}
Loading

0 comments on commit 3a13604

Please sign in to comment.