import net.sourceforge.phpeclipse.phpeditor.util.PHPWordDetector;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WhitespaceRule;
import org.eclipse.jface.text.rules.WordRule;
+
/**
* PHP Code Scanner
*/
public class PHPCodeScanner extends AbstractJavaScanner {
-
+
/**
* Rule to detect java operators.
*
}
}
+
+ protected class AccentStringRule implements IRule {
+
+ /** Token to return for this rule */
+ private final IToken fToken;
+
+ public AccentStringRule(IToken token) {
+ fToken = token;
+
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+ */
+ public IToken evaluate(ICharacterScanner scanner) {
+
+ int character = scanner.read();
+
+ if (character == '`') {
+
+ while (true) {
+ character = scanner.read();
+ if (character == '\\') {
+ character = scanner.read();
+ } else if (character == '`') {
+ return fToken;
+ }
+ }
+
+ } else {
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+ }
+
+ }
+
private class PHPWordRule extends WordRule {
private StringBuffer fBuffer = new StringBuffer();
return Token.UNDEFINED;
} else {
c = scanner.read();
- if (c == '=') { // <?=
+ if (c == '=') { // <?=
return getToken(IPreferenceConstants.PHP_TAG);
}
if (c != 'p' && c != 'P') {
IPreferenceConstants.PHP_KEYWORD,
IPreferenceConstants.PHP_FUNCTIONNAME,
IPreferenceConstants.PHP_VARIABLE,
- IPreferenceConstants.PHP_STRING,
+ IPreferenceConstants.PHP_STRING_DQ,
+ IPreferenceConstants.PHP_STRING_SQ,
IPreferenceConstants.PHP_TYPE,
IPreferenceConstants.PHP_CONSTANT,
IPreferenceConstants.PHP_DEFAULT,
List rules = new ArrayList();
Token token = getToken(IPreferenceConstants.PHP_SINGLELINE_COMMENT);
// Add rule for single line comments.
- rules.add(new EndOfLineRule("//", token)); //$NON-NLS-1$
- rules.add(new EndOfLineRule("#", token)); //$NON-NLS-1$
+ // rules.add(new EndOfLineRule("//", token)); //$NON-NLS-1$
+ // rules.add(new EndOfLineRule("#", token)); //$NON-NLS-1$
// Add rule for strings and character constants.
- token = getToken(IPreferenceConstants.PHP_STRING);
- rules.add(new MultiLineRule("\"", "\"", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
- rules.add(new MultiLineRule("`", "`", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
- rules.add(new MultiLineRule("'", "'", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
+ // token = getToken(IPreferenceConstants.PHP_STRING_SQ);
+ // rules.add(new SingleQuoteStringRule(token));
+ // token = getToken(IPreferenceConstants.PHP_STRING_DQ);
+ // rules.add(new DoubleQuoteStringRule(token));
+ rules.add(new AccentStringRule(token));
token = getToken(IPreferenceConstants.PHP_MULTILINE_COMMENT);
rules.add(new MultiLineRule("/*", "*/", token)); //$NON-NLS-2$ //$NON-NLS-1$