Corrections.
5 #include "semantic_helper.hh"
7 #define MAX_ID_TABLE_NO 1024
8 char* id_table[MAX_ID_TABLE_NO];
17 int yyerror(const char *str);
18 void yyrestart(FILE* file);
23 CONSTRNT PATTERN FLOWP COM
24 QUOTE THAN FROM UNTIL ON
33 %token <integer> INTEGER
36 %token <string> STRING
41 %token <integer> GREATER
51 %token <integer> ROUTE
57 %token <integer> EQUIP
59 %token <integer> TRAVEL_TYPE
60 %token <integer> TIMESEP
66 %type <string> constrnt
68 %type <integer> string_array
69 %type <integer> int_array
70 %type <integer> int_pt
71 %type <integer> char_pt
72 %type <integer> string_pt
73 %type <integer> string_array_pt
74 %type <integer> char_array_pt
75 %type <integer> int_op
76 %type <integer> string_op
77 %type <integer> string_array_op
78 %type <integer> string_string_array_op
79 %type <integer> si_unit
87 | error ')' { yyerrok; yyclearin;}
90 rule: pttrn { if (!pattern($1)) printf("Error: %s\n", last_error()); }
91 | constrnt { if (!constraint($1)) printf("Error: %s\n", last_error()); }
92 | flowp { if (!flowpoint($1)) printf("Error: %s\n", last_error()); }
96 flowp: FLOWP STRING '(' flowp_entry ')' { $$ = $2; }
99 flowp_entry: pttrn_lbl ':' constrnt_lbl
102 pttrn_lbl: STRING { if (!pattern_id($1)) printf("Error: %s\n", last_error()); }
105 constrnt_lbl: STRING { if (!constraint_id($1)) printf("Error: %s\n", last_error()); }
108 constrnt: CONSTRNT STRING '(' cterm ')' { $$ = $2; }
111 cterm: TIMESEP AT string IS INTEGER si_unit
112 { intpt_string_int_cterm(PT_TIMESEP, $3, $5 * $6, 0, 0, 0); }
113 | TIMESEP AT string_array IS INTEGER si_unit
114 { intpt_stringarray_int_cterm(PT_TIMESEP, $3, $5 * $6, 0, 0, 0); }
115 | TIMESEP AT string IS INTEGER si_unit FROM INTEGER UNTIL INTEGER
116 { intpt_string_int_cterm(PT_TIMESEP, $3, $5 * $6, $8, $10, 0); }
117 | TIMESEP AT string_array IS INTEGER si_unit FROM INTEGER UNTIL INTEGER
118 { intpt_stringarray_int_cterm(PT_TIMESEP, $3, $5 * $6, $8, $10, 0); }
120 | TIMESEP AT string IS INTEGER si_unit AT FL int_array
121 { intpt_string_int_cterm(PT_TIMESEP, $3, $5 * $6, 0, 0, $9); }
122 | TIMESEP AT string_array IS INTEGER si_unit AT FL int_array
123 { intpt_stringarray_int_cterm(PT_TIMESEP, $3, $5 * $6, 0, 0, $9); }
124 | TIMESEP AT string IS INTEGER si_unit FROM INTEGER UNTIL INTEGER AT FL int_array
125 { intpt_string_int_cterm(PT_TIMESEP, $3, $5 * $6, $8, $10, $13); }
126 | TIMESEP AT string_array IS INTEGER si_unit FROM INTEGER UNTIL INTEGER AT FL int_array
127 { intpt_stringarray_int_cterm(PT_TIMESEP, $3, $5 * $6, $8, $10, $13); }
135 if (!strcmp($1, "s")) { $$ = 1; }
136 else if (!strcmp($1, "min")) { $$ = 60; }
140 pttrn: PATTERN STRING '(' term ')' { $$ = $2; }
141 | PATTERN '(' term ')' { $$ = get_pattern_id(); }
144 term: int_pt int_op INTEGER
145 { intpt_int_term($2, $1, $3); }
147 | char_pt string_op string
148 { charpt_char_term($2, $1, $3); }
150 | string_pt string_op string
151 { stringpt_string_term($2, $1, $3); }
153 | string_array_pt string_array_op string_array
154 { stringarraypt_stringarray_term($2, $1, $3); }
156 | string_array string_array_op string_array_pt
162 else if ($2 == OT_NOTIN_C)
166 stringarraypt_stringarray_term($2, $3, $1);
169 | string string_string_array_op string_array_pt
175 else if ($2 == OT_NOTIN_C)
179 stringarraypt_string_term($2, $3, $1);
182 | string string_string_array_op char_array_pt
188 else if ($2 == OT_NOTIN_C)
192 chararraypt_char_term($2, $3, $1);
205 int_op: IS { $$ = OT_IS; }
206 | IS NOT { $$ = OT_ISNOT; }
207 | GREATER THAN { $$ = OT_GREATER; }
208 | LESS THAN { $$ = OT_LESS; }
211 string_op: IS { $$ = OT_IS; }
212 | IS NOT { $$ = OT_ISNOT; }
215 string_array_op:IS { $$ = OT_IS; }
216 | IS NOT { $$ = OT_ISNOT; }
217 | IN { $$ = OT_IN_P; }
218 | NOT IN { $$ = OT_NOTIN_P; }
221 string_string_array_op: IN { $$ = OT_IN_P; }
222 | NOT IN { $$ = OT_NOTIN_P; }
225 int_array: '[' ints ']' { $$ = integer_array(); }
232 int: INTEGER { integer($1); $$ = $1; }
235 string_array: '[' strings ']' { $$ = string_array(); }
238 strings: | strings ',' string
242 int_pt: TAS { $$ = PT_TAS; }
245 char_pt: FTYP { $$ = PT_FTYP; }
247 string_pt: ADEP { $$ = PT_ADEP; }
248 | ADES { $$ = PT_ADES; }
249 | RWY { $$ = PT_RWY; }
250 | ATYP { $$ = PT_ATYP; }
251 | COPX { $$ = PT_COPX; }
252 | FRUL { $$ = PT_FRUL; }
253 | RFL { $$ = PT_RFL; }
254 | TRAVEL_TYPE { $$ = PT_TRAVEL_TYPE; }
257 string_array_pt:ROUTE { $$ = PT_ROUTE; }
260 char_array_pt: EQUIP { $$ = PT_EQUIP; }
263 string: QUOTE STRING QUOTE { string($2); $$ = $2; }
267 #include "atccl_parser.c"
269 void clear_id_table()
272 for (i = 0; i < id_table_no; ++i)
286 int semantic_error(const char* str)
288 if (errorNo < maxErrorNo)
290 errors[errorNo].line = -1;
291 strcpy(errors[errorNo].text, "");
292 strcpy(errors[errorNo].error, str);
298 int yyerror(const char *str)
300 if (errorNo < maxErrorNo)
302 errors[errorNo].line = line_no;
303 strcpy(errors[errorNo].text, yytext);
304 strcpy(errors[errorNo].error, str);
310 int parse_syntax(FILE* file, ErrorType* errors_, int maxErrorNo_, int passes)
314 maxErrorNo = maxErrorNo_;
324 if (!complete_semantics())
326 semantic_error(last_error());