1 /* $Id: pascal.c,v 1.3 1994/06/24 11:00:38 ceriel Exp $ */
3 /* Language dependant support; this one is for Pascal */
21 extern FILE *db_out, *db_in;
44 static struct langdep pascal = {
74 struct langdep *pascal_dep = &pascal;
81 fprintf(db_out, (c >= 040 && c < 0177) ? "'%c'" : "chr(%d)", c);
85 print_string(f, s, len)
90 register char *str = s;
93 while (*str && len > 0) {
95 if (*str++ == '\'') putc('\'', f);
101 extern long int_size;
107 if (! (int_size % size)) return size;
108 if (! (size % int_size)) return size;
109 return ((size + int_size - 1) / int_size) * int_size;
163 register char *np = &buf[0];
167 if (np < &buf[512]) *np++ = ch;
173 if (np < &buf[512]) *np++ = '.';
178 if (np < &buf[512]) *np++ = ch;
183 if (ch == 'E' || ch == 'e') {
187 if (np < &buf[512]) *np++ = ch;
189 if (ch == '+' || ch == '-') {
190 /* Signed scalefactor
192 if (np < &buf[512]) *np++ = ch;
197 if (np < &buf[512]) *np++ = ch;
199 } while (is_dig(ch));
202 error("bad scale factor");
209 if (np >= &buf[512]) {
212 error("constant too long");
216 error("real constant too long");
219 else if (! real_mode) {
220 tok.ival = atol(buf);
223 tok.fval = atof(buf);
232 register char *p = &buf[0];
233 register struct idf *id;
236 if (isupper(c)) c = tolower(c);
237 if (p - buf < 512) *p++ = c;
242 /* now recognize and, div, in, mod, not, or */
245 if (strcmp(buf, "and") == 0) {
251 if (strcmp(buf, "div") == 0) {
257 if (strcmp(buf, "in") == 0) {
263 if (strcmp(buf, "mod") == 0) {
269 if (strcmp(buf, "not") == 0) {
275 if (strcmp(buf, "or") == 0) {
281 id = str2idf(buf, 1);
283 tok.str = id->id_text;
284 return id->id_reserved ? id->id_reserved : NAME;
311 return PREF_OR_BIN_OP;
314 return PREF_OR_BIN_OP;
327 tok.ival = E_NOTEQUAL;
331 tok.ival = E_LTEQUAL;
340 tok.ival = E_GTEQUAL;
350 error((c >= 040 && c < 0177) ? "%s'%c'" : "%s'\\0%o'", "illegal character ", c);
361 register int len = 0;
373 error("newline in string");
380 tok.str = Salloc(buf, (unsigned) len);
391 switch(p->t_whichoper) {
394 print_node(f, p->t_args[0], 0);
398 print_node(f, p->t_args[0], 0);
402 print_node(f, p->t_args[0], 0);
405 print_node(f, p->t_args[0], 0);
411 if (p->t_whichoper == E_ARRAY) {
412 print_node(f, p->t_args[0], 0);
414 print_node(f, p->t_args[1], 0);
418 if (p->t_whichoper == E_SELECT) {
419 print_node(f, p->t_args[0], 0);
421 print_node(f, p->t_args[1], 0);
425 print_node(f, p->t_args[0], 0);
426 switch(p->t_whichoper) {
470 print_node(f, p->t_args[1], 0);
479 /* No problems of this kind in Pascal */