1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
35 };
40 charcount--;
42 }
47 }
51 charcount++;
52 };
62 //lab:
63 //if (linenum==1059) {
64 // linenum=1059;
65 //}
75 }
128 //////
131 //////
138 }
147 ncount++;
149 }
150 //real_constant=real_constant+(float)integer_constant/(10*ncount);
151 // j-a-s-d: little but important bugfix, it was corrupting the decimal part
153 /*
154 i=1;
155 j=0;
156 ncount=1;
157 real_constant=(float)integer_constant;
158 while (((c>='0') && (c<='9'))) {
159 j=j*10+c-48;
160 i++;
161 c=nextchar();
162 }
163 real_constant=real_constant+(j/(10*i));
164 */
176 }
180 }
184 }
197 //goto lab;
202 }
218 }
222 }
226 }
232 }
233 }
247 }
250 i++;
252 }
255 }
292 }
310 }
313 //goto lab;
321 // j-a-s-d: removing $R and $V to avoid ambiguities
322 /*
323 if (c=='$') {
324 c=nextchar();
325 if (c=='R') { //real type switch
326 c=nextchar();
327 if (c=='-') mathType=1;
328 if (c=='+') mathType=2;
329 }
330 if (c=='V') { //preverify_bytecode switch
331 c=nextchar();
332 if (c=='-') goverify=0;
333 if (c=='+') goverify=1;
334 }
335 }
336 */
338 //goto lab;
340 }
343 }
345 //#define CST_INTEGER 0
346 //#define CST_REAL 1
347 //#define CST_BOOLEAN 2
348 //#define CST_CHAR 3
349 //#define CST_STRING 4
350 //
351 //#define OP_MOD 5
352 //#define OP_DIV 6
353 //#define OP_PLUS 7
354 //#define OP_MINUS 8
355 //#define OP_MULT 9
356 //#define OP_SLASH 10
357 //#define OP_EQUAL 11
358 //#define SEMI_COLON 18
359 //#define COLON 19
360 //#define OP_ASSIGN 20
361 //#define OP_LESS 21
362 //#define OP_GREATER 22
363 //#define OP_LESS_EQUAL 23
364 //#define OP_GREATER_EQUAL 24
365 //#define OP_NOT_EQUAL 25
366 //#define DOT 26
367 //#define OPEN_SQ_BR 27
368 //#define CLOSE_SQ_BR 28
369 //#define OPEN_BR 34
370 //#define CLOSE_BR 35
371 //#define IDENTIFIER 57
372 //#define COMMA 58
373 //#define DOTDOT 59
374 //#define END_OF_INPUT 100
375 /*
376 #define CST_INTEGER 0
377 #define CST_REAL 1
378 #define CST_BOOLEAN 2
379 #define CST_CHAR 3
380 #define CST_STRING 4
381 #define OP_MOD 5
382 #define OP_DIV 6
383 #define OP_PLUS 7
384 #define OP_MINUS 8
385 #define OP_MULT 9
386 #define OP_SLASH 10
387 #define OP_EQUAL 11
388 #define KWD_BEGIN 12
389 #define KWD_END 13
390 #define OP_AND 14
391 #define KWD_PROGRAM 15
392 #define KWD_PROCEDURE 16
393 #define KWD_FUNCTION 17
394 #define SEMI_COLON 18
395 #define COLON 19
396 #define OP_ASSIGN 20
397 #define OP_LESS 21
398 #define OP_GREATER 22
399 #define OP_LESS_EQUAL 23
400 #define OP_GREATER_EQUAL 24
401 #define OP_NOT_EQUAL 25
402 #define DOT 26
403 #define OPEN_SQ_BR 27
404 #define CLOSE_SQ_BR 28
405 #define KWD_VAR 29
406 #define KWD_FOR 30
407 #define KWD_TO 31
408 #define KWD_DOWNTO 32
409 #define KWD_DO 33
410 #define OPEN_BR 34
411 #define CLOSE_BR 35
412 #define KWD_CONST 36
413 #define KWD_TYPE 37
414 #define KWD_IF 38
415 #define KWD_THEN 39
416 #define KWD_ELSE 40
417 #define KWD_CASE 41
418 #define KWD_OF 42
419 #define KWD_WHILE 43
420 #define KWD_REPEAT 44
421 #define KWD_UNTIL 45
422 #define KWD_WITH 46
423 #define KWD_PACKED 47
424 #define KWD_ARRAY 48
425 #define OP_OR 49
426 #define KWD_FILE 50
427 #define KWD_SET 51
428 #define KWD_RECORD 52
429 #define OP_IN 53
430 #define OP_NOT 54
431 #define OP_XOR 55
432 #define KWD_FORWARD 56
433 #define IDENTIFIER 57
434 #define COMMA 58
435 #define DOTDOT 59
436 #define KWD_BREAK 60
437 #define KWD_USES 61
438 #define KWD_UNIT 62
439 #define KWD_INTERFACE 63
440 #define KWD_IMPLEMENTATION 64
441 #define KWD_INITIALIZATION 65
442 #define KWD_FINALIZATION 66
443 #define END_OF_INPUT 100
445 /*
446 "mod" = (OP_MOD);
447 "div" = (OP_DIV);
448 "+" = (OP_PLUS);
449 "-" = (OP_MINUS);
450 "*" = (OP_MULT);
451 "/" = (OP_SLASH);
452 "=" = (OP_EQUAL);
453 "begin" = (KWD_BEGIN);
454 "end" = (KWD_END);
455 "and" = (OP_AND);
456 "program" = (KWD_PROGRAM);
457 "procedure" = (KWD_PROCEDURE);
458 "function" = (KWD_FUNCTION);
459 ";" = (SEMI_COLON);
460 ":" = (COLON);
461 ":=" = (OP_ASSIGN);
462 "<" = (OP_LESS);
463 ">" = (OP_GREATER);
464 "<=" = (OP_LESS_EQUAL);
465 ">=" = (OP_GREATER_EQUAL);
466 "<>" = (OP_NOT_EQUAL);
467 "." = (DOT);
468 ".." = (DOTDOT);
469 "[" = (OPEN_SQ_BR);
470 "]" = (CLOSE_SQ_BR);
471 "var" = (KWD_VAR);
472 "for" = (KWD_FOR);
473 "to" = (KWD_TO);
474 "downto" = (KWD_DOWNTO);
475 "do" = (KWD_DO);
476 "(" = (OPEN_BR);
477 ")" = (CLOSE_BR);
478 "const" = (KWD_CONST);
479 "type" = (KWD_TYPE);
480 "if" = (KWD_IF);
481 "then" = (KWD_THEN);
482 "else" = (KWD_ELSE);
483 "case" = (KWD_CASE);
484 "of" = (KWD_OF);
485 "while" = (KWD_WHILE);
486 "repeat" = (KWD_REPEAT);
487 "until" = (KWD_UNTIL);
488 "with" = (KWD_WITH);
489 "packed" = (KWD_PACKED);
490 "array" = (KWD_ARRAY);
491 "or" = (OP_OR);
492 "file" = (KWD_FILE);
493 "set" = (KWD_SET);
494 "record" = (KWD_RECORD);
495 "in" = (OP_IN);
496 "not" = (OP_NOT);
497 "xor" = (OP_XOR);
498 "forward" = (KWD_FORWARD);
499 "break" = (KWD_BREAK);
500 "," = (COMMA);
501 "uses" = (KWD_USES);
502 "unit" = (KWD_UNIT);
503 "interface" = (KWD_INTERFACE);
504 "implementation" = (KWD_IMPLEMENTATION);
505 "initialization" = (KWD_INITIALIZATION);
506 "finalization" = (KWD_FINALIZATION);
507 */
510 /*
511 c=nextchar();
512 i=0;
513 rep:
514 while (c!='\'') {
515 *p=c;
516 p=p+1;
517 i++;
518 c=nextchar();
519 }
520 c=nextchar();
521 if (c=='\'') {*p=c; p=p+1; i=i+1; c=nextchar(); goto rep;}
522 if (c=='#') {
523 j=0;
524 c=nextchar();
525 while (((c>='0') && (c<='9'))) {
526 j=j*10+c-48;
527 c=nextchar();
528 }
529 *p=(char)j;
530 p=p+1;
531 i=i+1;
532 goto rep;
533 }
534 */
536 /*
537 int getnum() { //get number
538 int sum;
539 sum=0;
540 ncount=1;
541 if (c=='$') {
542 c=nextchar();
543 do {
544 if ((c >= 'A') && (c <= 'Z')) {sum = sum*16+10+c-65; ncount=ncount+1;}
545 else if ((c >= 'a') && (c <= 'z')) {sum = sum*16+10+c-97; ncount=ncount+1;}
546 else if (('0'>=c) && (c<='9')) {sum = sum*16+c-48; ncount=ncount+1;}
547 else break;
548 c=nextchar();
549 } while (1==1);
550 } else {
551 while (('0'>=c) && (c<='9')) {
552 sum = sum*10+c-48;
553 ncount=ncount+1;
554 c=nextchar();
555 }
556 }
557 //if (numcount==1) backchar(255); //bad number
558 return sum;
559 }
560 */