Mercurial > hg > CbC > old > device
comparison mc-macro.c @ 349:b74b580c10f6
name table debug continue...
author | kono |
---|---|
date | Fri, 02 Jul 2004 14:14:24 +0900 |
parents | e77b3a7002ad |
children | 43099915f4c2 |
comparison
equal
deleted
inserted
replaced
348:e77b3a7002ad | 349:b74b580c10f6 |
---|---|
449 cheap->ptr--; | 449 cheap->ptr--; |
450 getline(); | 450 getline(); |
451 } | 451 } |
452 } | 452 } |
453 if (c=='\n') { | 453 if (c=='\n') { |
454 cheap->ptr--; | |
455 *cheap->ptr = '\0'; | 454 *cheap->ptr = '\0'; |
456 } | 455 } |
457 cheap = increment_cheap(cheap,body); | 456 cheap = increment_cheap(cheap,body); |
458 // fprintf(stderr,"%s\n",(char *)car(nptr->dsp)); | 457 // fprintf(stderr,"%s\n",(char *)car(nptr->dsp)); |
459 mode=i; | 458 mode=i; |
608 } | 607 } |
609 | 608 |
610 static int | 609 static int |
611 macro_eval(int macrop,char *body0,int history) | 610 macro_eval(int macrop,char *body0,int history) |
612 { | 611 { |
613 int c,len; | 612 int c/*,len*/; |
613 int sch; char *schptr; | |
614 int in_quote = 0; | 614 int in_quote = 0; |
615 int in_wquote = 0; | 615 int in_wquote = 0; |
616 char *macro; | 616 char *macro; |
617 char *body = body0; | 617 char *body = body0; |
618 char **expand; | 618 char **expand; |
640 in_quote = 1; | 640 in_quote = 1; |
641 } else if (c=='#' && *body=='#') { | 641 } else if (c=='#' && *body=='#') { |
642 // name concatenation. skip ## and re-eval macro line. | 642 // name concatenation. skip ## and re-eval macro line. |
643 mconcat = 1; body++; continue; | 643 mconcat = 1; body++; continue; |
644 } else if (alpha(c)) { | 644 } else if (alpha(c)) { |
645 #if 0 | |
646 body--; // ungetc | |
645 nptrm = get_name(body,&len); | 647 nptrm = get_name(body,&len); |
646 body += len; | 648 c = *body; |
649 #else | |
650 sch = ch; schptr = chptr; ch = c; chptr = body; | |
651 nptrm = get_name_from_chptr(); | |
652 body = chptr; c = ch; | |
647 body--; // ungetc | 653 body--; // ungetc |
654 ch = sch; chptr = schptr; | |
655 #endif | |
648 nptrm = name_space_search(nptrm,MACRO); | 656 nptrm = name_space_search(nptrm,MACRO); |
649 macro = (char *)car(nptrm->dsp); | 657 macro = (char *)car(nptrm->dsp); |
650 switch(nptrm->sc) { | 658 switch(nptrm->sc) { |
651 case FMACRO: | 659 case FMACRO: |
652 if (c==' '||c=='\t') { | 660 if (c==' '||c=='\t') { |
653 while (c==' '||c=='\t') c=*body++; | 661 while (c==' '||c=='\t') c=*body++; |
654 body--; | 662 body--; |
655 } | 663 } |
656 if(c!='(') error(MCERR); | 664 if(c!='(') error(MCERR); |
665 *cheap->ptr = 0; | |
657 cheap = increment_cheap(cheap,expand); | 666 cheap = increment_cheap(cheap,expand); |
658 body++; | 667 body++; |
659 macrop = macro_function(macrop,&body,nptrm, | 668 macrop = macro_function(macrop,&body,nptrm, |
660 list2((int)macro,history)); | 669 list2((int)macro,history)); |
661 macrop = list2((int)cheap->ptr,macrop); | 670 macrop = list2((int)cheap->ptr,macrop); |
672 break; | 681 break; |
673 } | 682 } |
674 default: | 683 default: |
675 macro = nptrm->nm; | 684 macro = nptrm->nm; |
676 case LMACRO: | 685 case LMACRO: |
677 while((*cheap->ptr = *macro++)); | 686 while((*cheap->ptr = *macro++)/* && len-- */) |
678 cheap = increment_cheap(cheap,expand); | 687 cheap = increment_cheap(cheap,expand); |
679 cheap->ptr--; | |
680 } | 688 } |
681 continue; | 689 continue; |
682 } | 690 } |
683 *cheap->ptr = c; | 691 *cheap->ptr = c; |
684 cheap = increment_cheap(cheap,expand); | 692 cheap = increment_cheap(cheap,expand); |