1 2 package com.sun.java_cup.internal; 3 4 7 public class parse_action_row { 8 9 10 11 12 13 16 public parse_action_row() 17 { 18 19 if (_size <= 0 ) _size = terminal.number(); 20 21 22 under_term = new parse_action[size()]; 23 24 25 for (int i=0; i<_size; i++) 26 under_term[i] = new parse_action(); 27 } 28 29 30 31 32 33 34 protected static int _size = 0; 35 36 37 public static int size() {return _size;} 38 39 40 41 42 protected static int reduction_count[] = null; 43 44 45 46 47 48 49 public parse_action under_term[]; 50 51 52 53 56 public int default_reduce; 57 58 59 60 61 62 70 public void compute_default() 71 { 72 int i, prod, max_prod, max_red; 73 74 75 if (reduction_count == null) 76 reduction_count = new int[production.number()]; 77 78 79 for (i = 0; i < production.number(); i++) 80 reduction_count[i] = 0; 81 max_prod = -1; 82 max_red = 0; 83 84 85 for (i = 0; i < size(); i++) 86 if (under_term[i].kind() == parse_action.REDUCE) 87 { 88 90 prod = ((reduce_action)under_term[i]).reduce_with().index(); 91 reduction_count[prod]++; 92 if (reduction_count[prod] > max_red) 93 { 94 max_red = reduction_count[prod]; 95 max_prod = prod; 96 } 97 } 98 99 100 default_reduce = max_prod; 101 } 102 103 104 105 } 106 107 | Popular Tags |