comparison dwtx/jface/text/rules/NumberRule.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents eb21d3dfc767
children eb98a5cbfd78
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
48 * An implementation of <code>IRule</code> detecting a numerical value. 48 * An implementation of <code>IRule</code> detecting a numerical value.
49 */ 49 */
50 public class NumberRule : IRule { 50 public class NumberRule : IRule {
51 51
52 /** Internal setting for the un-initialized column constraint */ 52 /** Internal setting for the un-initialized column constraint */
53 protected static final int UNDEFINED= -1; 53 protected static const int UNDEFINED= -1;
54 /** The token to be returned when this rule is successful */ 54 /** The token to be returned when this rule is successful */
55 protected IToken fToken; 55 protected IToken fToken;
56 /** The column constraint */ 56 /** The column constraint */
57 protected int fColumn= UNDEFINED; 57 protected int fColumn= UNDEFINED;
58 58
61 * token when a numerical sequence is detected. 61 * token when a numerical sequence is detected.
62 * 62 *
63 * @param token the token to be returned 63 * @param token the token to be returned
64 */ 64 */
65 public this(IToken token) { 65 public this(IToken token) {
66 Assert.isNotNull(token); 66 Assert.isNotNull(cast(Object)token);
67 fToken= token; 67 fToken= token;
68 } 68 }
69 69
70 /** 70 /**
71 * Sets a column constraint for this rule. If set, the rule's token 71 * Sets a column constraint for this rule. If set, the rule's token
84 /* 84 /*
85 * @see IRule#evaluate(ICharacterScanner) 85 * @see IRule#evaluate(ICharacterScanner)
86 */ 86 */
87 public IToken evaluate(ICharacterScanner scanner) { 87 public IToken evaluate(ICharacterScanner scanner) {
88 int c= scanner.read(); 88 int c= scanner.read();
89 if (Character.isDigit(cast(wchar)c)) { 89 if (Character.isDigit(cast(char)c)) {
90 if (fColumn is UNDEFINED || (fColumn is scanner.getColumn() - 1)) { 90 if (fColumn is UNDEFINED || (fColumn is scanner.getColumn() - 1)) {
91 do { 91 do {
92 c= scanner.read(); 92 c= scanner.read();
93 } while (Character.isDigit(cast(wchar) c)); 93 } while (Character.isDigit(cast(char) c));
94 scanner.unread(); 94 scanner.unread();
95 return fToken; 95 return fToken;
96 } 96 }
97 } 97 }
98 98