39 DUMMY_TR("Invalid argument"), /* E_TOKZ_INVALID_ARGUMENT */ |
39 DUMMY_TR("Invalid argument"), /* E_TOKZ_INVALID_ARGUMENT */ |
40 DUMMY_TR("End of statement expected"), /* E_TOKZ_EOS_EXPECTED */ |
40 DUMMY_TR("End of statement expected"), /* E_TOKZ_EOS_EXPECTED */ |
41 DUMMY_TR("Too few arguments"), /* E_TOKZ_TOO_FEW_ARGS */ |
41 DUMMY_TR("Too few arguments"), /* E_TOKZ_TOO_FEW_ARGS */ |
42 DUMMY_TR("Too many arguments"), /* E_TOKZ_TOO_MANY_ARGS */ |
42 DUMMY_TR("Too many arguments"), /* E_TOKZ_TOO_MANY_ARGS */ |
43 DUMMY_TR("Maximum section nestin level exceeded"), /* E_TOK_Z_MAX_NEST */ |
43 DUMMY_TR("Maximum section nestin level exceeded"), /* E_TOK_Z_MAX_NEST */ |
44 DUMMY_TR("Unexpected end of statement"), /* E_TOKZ_UNEXPECTED_EOS */ |
|
45 DUMMY_TR("Identifier expected"), /* E_TOKZ_IDENTIFIER_EXPECTED */ |
44 DUMMY_TR("Identifier expected"), /* E_TOKZ_IDENTIFIER_EXPECTED */ |
|
45 DUMMY_TR("Starting brace ('{') expected"), /* E_TOKZ_LBRACE_EXPECTED */ |
46 }; |
46 }; |
47 |
47 |
48 |
48 |
49 /* */ |
49 /* */ |
50 |
50 |
51 #define STRBLEN 32 |
51 #define STRBLEN 32 |
52 |
52 |
53 #define STRING_DECL(X) char* X=NULL; char X##_tmp[STRBLEN]; int X##_tmpl=0 |
53 #define STRING_DECL(X) int err=0; char* X=NULL; char X##_tmp[STRBLEN]; int X##_tmpl=0 |
54 #define STRING_DECL_P(X, P) char* X=NULL; char X##_tmp[STRBLEN]=P; int X##_tmpl=sizeof(P)-1 |
54 #define STRING_DECL_P(X, P) int err=0; char* X=NULL; char X##_tmp[STRBLEN]=P; int X##_tmpl=sizeof(P)-1 |
55 #define STRING_APPEND(X, C) {if(!_string_append(&X, X##_tmp, &X##_tmpl, c)) return -ENOMEM;} |
55 #define STRING_APPEND(X, C) {if(!_string_append(&X, X##_tmp, &X##_tmpl, c)) err=-ENOMEM;} |
56 #define STRING_FREE(X) if(X!=NULL) free(X) |
56 #define STRING_FREE(X) if(X!=NULL) free(X) |
57 #define STRING_FINISH(X) {if(!_string_finish(&X, X##_tmp, X##_tmpl)) return -ENOMEM;} |
57 #define STRING_FINISH(X) {if(err!=0) return err; if(!_string_finish(&X, X##_tmp, X##_tmpl)) err=-ENOMEM;} |
58 |
58 |
59 |
59 |
60 static bool _string_append(char **p, char *tmp, int *tmplen, char c) |
60 static bool _string_append(char **p, char *tmp, int *tmplen, char c) |
61 { |
61 { |
62 char *tmp2; |
62 char *tmp2; |
625 } |
633 } |
626 |
634 |
627 continue; |
635 continue; |
628 |
636 |
629 case '/': |
637 case '/': |
630 { |
638 c2=GETCH(); |
631 c2=GETCH(); |
639 |
632 |
640 if(c2=='='){ |
633 if(c2=='='){ |
641 TOK_SET_OP(tok, OP_AS_DIV); |
634 TOK_SET_OP(tok, OP_AS_DIV); |
642 return TRUE; |
635 return TRUE; |
|
636 } |
|
637 |
|
638 if(c2!='*'){ |
|
639 UNGETCH(c2); |
|
640 TOK_SET_OP(tok, OP_DIV); |
|
641 return TRUE; |
|
642 } |
|
643 |
|
644 if(tokz->flags&TOKZ_READ_COMMENTS){ |
|
645 e=scan_c_comment(tok, tokz); |
|
646 break; |
|
647 }else if((e=skip_c_comment(tokz))){ |
|
648 break; |
|
649 } |
|
650 |
|
651 continue; |
|
652 } |
643 } |
|
644 |
|
645 if(c2!='*'){ |
|
646 UNGETCH(c2); |
|
647 TOK_SET_OP(tok, OP_DIV); |
|
648 return TRUE; |
|
649 } |
|
650 |
|
651 if(tokz->flags&TOKZ_READ_COMMENTS){ |
|
652 e=scan_c_comment(tok, tokz); |
|
653 break; |
|
654 }else if((e=skip_c_comment(tokz))){ |
|
655 break; |
|
656 } |
|
657 |
|
658 continue; |
653 |
659 |
654 case '\"': |
660 case '\"': |
655 e=scan_string(tok, tokz, TRUE); |
661 e=scan_string(tok, tokz, TRUE); |
656 break; |
662 break; |
657 |
663 |
699 |
713 |
700 finfo->file=tokz->file; |
714 finfo->file=tokz->file; |
701 finfo->name=tokz->name; |
715 finfo->name=tokz->name; |
702 finfo->line=tokz->line; |
716 finfo->line=tokz->line; |
703 finfo->ungetc=tokz->ungetc; |
717 finfo->ungetc=tokz->ungetc; |
704 |
718 finfo->ungettok=tokz->ungettok; |
|
719 |
705 return TRUE; |
720 return TRUE; |
706 } |
721 } |
707 |
722 |
708 |
723 |
709 bool tokz_pushf_file(Tokenizer *tokz, FILE *file) |
724 bool tokz_pushf_file(Tokenizer *tokz, FILE *file) |
837 |
854 |
838 tokz->file=finfo->file; |
855 tokz->file=finfo->file; |
839 tokz->name=finfo->name; |
856 tokz->name=finfo->name; |
840 tokz->line=finfo->line; |
857 tokz->line=finfo->line; |
841 tokz->ungetc=finfo->ungetc; |
858 tokz->ungetc=finfo->ungetc; |
842 |
859 tokz->ungettok=finfo->ungettok; |
|
860 |
843 if(tokz->filestack_n==0){ |
861 if(tokz->filestack_n==0){ |
844 free(tokz->filestack); |
862 free(tokz->filestack); |
845 tokz->filestack=NULL; |
863 tokz->filestack=NULL; |
846 }else if(shrink){ |
864 }else if(shrink){ |
847 finfo=REALLOC_N(tokz->filestack, Tokenizer_FInfo, |
865 finfo=REALLOC_N(tokz->filestack, Tokenizer_FInfo, |