/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk
1 by Gustav Hartvigsson
* Initial code - far from done
1
namespace VQDR.Expression {
2
  
3
  public abstract class ValueToken : Token {
4
    protected ValueToken (int position) {
5
      base (position);
6
    }
7
  }
8
  
9
  public static ValueToken? init_constant_token (long val, int position) {
10
    //return new ConstantValueToken (val, position);
11
    return null;
12
  }
13
  
14
  public static ValueToken? init_variable_token (string name, int position) {
15
    //return new VariableValueToken (name, position);
16
    return null;
17
  }
18
  
19
  public static long parse_raw_value (string str) {
20
    long ret_val = 0;
21
    int i_of_dot = str.index_of_char ('.');
22
    if (i_of_dot >= 0) {
23
    
24
      // Get the decimal value from the string, if such a thing exists.
25
      if ((str.length - 1 > i_of_dot)) {
26
        ret_val = long.parse ((str + "000").substring (i_of_dot + 1));
27
        
28
      }
29
      
30
      // Normalise the digits.
31
      while (ret_val > Token.VALUES_PRECISION_FACTOR) {
32
        ret_val = ret_val / 10;
33
      }
34
      
35
      // Add intiger value
36
      ret_val = ret_val + (long.parse ("0" + str.substring (0, i_of_dot)) * Token.VALUES_PRECISION_FACTOR);
37
    } else {
38
      ret_val = long.parse (str) * Token.VALUES_PRECISION_FACTOR;
39
    }
40
    return ret_val;
41
  }
42
  
43
  
44
}