01: package org.jicengine.expression;
02:
03: import org.jicengine.operation.VariableValueOperation;
04: import org.jicengine.operation.Operation;
05:
06: /**
07: *
08: * <p>
09: * Copyright (C) 2004 Timo Laitinen
10: * </p>
11: * @author .timo
12: */
13:
14: public class VariableParser implements Parser {
15:
16: public Operation parse(String expression) throws SyntaxException {
17: char[] chars = expression.toCharArray();
18: char character;
19:
20: if (Character.isJavaIdentifierStart(chars[0])) {
21: for (int i = 1; i < chars.length; i++) {
22: if (!Character.isJavaIdentifierPart(chars[i])) {
23: return null;
24: }
25: }
26: return new VariableValueOperation(expression);
27: } else {
28: return null;
29: }
30:
31: /*
32: if(Character.isLetter(chars[0]) && chars[0] != '-' ) {
33: for(int i = 1; i < chars.length; i++) {
34: character = chars[i];
35: if(character == OPERATION_SEPARATOR) {
36: return null;
37: }
38: else if(character == METHOD_PARAMS_START || character == METHOD_PARAMS_END) {
39: return null;
40: }
41: else {
42: // continue..
43: }
44: }
45: return new VariableValueOperation(expression);
46: }
47: else {
48: return null;
49: }
50: */
51: }
52: }
|