/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/libvqdr/token.vala

  • Committer: Gustav Hartvigsson
  • Date: 2021-09-09 20:40:16 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210909204016-u577zci01ir6izby
* Added DiceOperatiorToken
* Removed warning about unused to_string () method
* Small spelling errors
* Cleaned up the Token.priority stuff.
* Added missing mandetory_num_child to ConstantValueToken.
* Made the ValueToken factory actually produce something.
* Reordered the if/else if chain in AddOperationToken.evaluate_self ()
  so it can actually work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
     * higher number is higher priority, and is to be done befroe those
25
25
     * with lower number.
26
26
     */
27
 
    enum Prio {
 
27
    public enum Prio {
28
28
      /** Priority for assignment "=" operator */
29
29
      ASSIGNMENT = 0,
30
30
      /** Priority for conditional OR "||" operator */
51
51
      VALUE;
52
52
      
53
53
      /** get the name of the priority */
54
 
      string to_string () {
 
54
      public string to_string () {
55
55
        switch (this) {
56
56
          case ASSIGNMENT:
57
57
            return "prio: assigment";
85
85
    /* ********************************************************************** */
86
86
    
87
87
    /**
88
 
     * tells weather the token is right associative or not.
 
88
     * tells whether the token is right associative or not.
89
89
     */
90
90
    public bool right_assosiative {get;set; default = false;}
91
91
    
92
 
    
93
 
    private int real_priority;
94
 
    
95
92
    /** The parent token of this token*/
96
93
    protected unowned Token? parent {protected get; protected set;}
97
94
    
98
 
    public virtual int priority {public get {
99
 
      return __get_priority ();
100
 
     } protected construct set {
101
 
       __set_priority (value);
102
 
     }}
 
95
    public virtual int priority {public get; protected construct set;}
103
96
    
104
97
    /** Starting position of the token in the expression */
105
98
    protected int position;
155
148
      this.position = position;
156
149
    }
157
150
    
 
151
    
158
152
    /**
159
153
     * Reorders result_min_value and result_max_value, so that
160
 
     * result_max varue is the bigger of the two, and
 
154
     * result_max_value is the bigger of the two, and
161
155
     * result_min_value is the smaller.
162
156
     */
163
157
    protected void reorder_max_min_values () {
245
239
     * @throws GLib.Error an error if an error has orrured in the evaluation of the tree.
246
240
     */
247
241
    protected abstract void evaluate_self (Context instance) throws GLib.Error;
248
 
    
249
 
    /* *********** IGNORE THE MESS I HAVE CREATED FOR MY SELF *************** */
250
 
    /** IGNORE ME */
251
 
    protected void __set_priority (int prio) {
252
 
      real_priority = prio;
253
 
    }
254
 
    
255
 
    /** IGNORE ME*/
256
 
    protected int __get_priority () {
257
 
      return real_priority;
258
 
    }
259
 
    
260
 
    
261
242
  }
262
243
  
263
244
}