* PHP Code Scanner
*/
public class PHPCodeScanner extends AbstractJavaScanner {
-
+
/**
* Rule to detect java operators.
*
}
}
- protected class SingleQuoteStringRule implements IRule {
-
- /** Token to return for this rule */
- private final IToken fToken;
-
- public SingleQuoteStringRule(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;
- }
- }
-
- }
-
protected class AccentStringRule implements IRule {
/** Token to return for this rule */
int character = scanner.read();
- if (character=='`') {
-
+ if (character == '`') {
+
while (true) {
character = scanner.read();
if (character == '\\') {
} else if (character == '`') {
return fToken;
}
- }
-
- } else {
- scanner.unread();
- return Token.UNDEFINED;
- }
- }
-
- }
-
- protected class DoubleQuoteStringRule implements IRule {
-
- /** Token to return for this rule */
- private final IToken fToken;
-
- public DoubleQuoteStringRule(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') {
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_SQ);
-// rules.add(new SingleQuoteStringRule(token));
-// token = getToken(IPreferenceConstants.PHP_STRING_DQ);
-// rules.add(new DoubleQuoteStringRule(token));
+ // 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);