aboutsummaryrefslogtreecommitdiffstats
path: root/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/VariableRule.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/VariableRule.java')
-rw-r--r--org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/VariableRule.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/VariableRule.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/VariableRule.java
new file mode 100644
index 0000000..c615a9f
--- /dev/null
+++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/VariableRule.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2009 Ken Gilmer
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ken Gilmer - initial API and implementation
+ *******************************************************************************/
+package org.openembedded.bc.ui.editors.bitbake;
+
+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;
+
+final class VariableRule implements IRule {
+
+ /** Token to return for this rule */
+ private final IToken fToken;
+
+ /**
+ * Creates a new operator rule.
+ *
+ * @param token
+ * Token to use for this rule
+ */
+ public VariableRule(IToken token) {
+ fToken = token;
+ }
+
+ public IToken evaluate(ICharacterScanner scanner) {
+ if (scanner.getColumn() > 0) {
+ return Token.UNDEFINED;
+ }
+
+ int i = scanner.read();
+ int c = 1;
+
+ if (!Character.isLetter(i) && i != 10) {
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+
+ int p = i;
+
+ while (i != ICharacterScanner.EOF && i != 10) {
+ p = i;
+ i = scanner.read();
+ c++;
+
+ if (i == '=') {
+ scanner.unread();
+
+ if (p == '?' || p == '+') {
+ scanner.unread();
+ }
+ return fToken;
+ }
+ }
+
+ for (int t = 0; t < c; t++) {
+ scanner.unread();
+ }
+
+ return Token.UNDEFINED;
+ }
+} \ No newline at end of file