Mercurial > projects > ldc
comparison dmd2/lexer.c @ 847:356e65836fb5
Merged DMD 2.021 frontend.
Removed generated files from dmd/dmd2 dirs.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 13 Dec 2008 16:14:37 +0100 |
parents | f04dde6e882c |
children | 638d16625da2 |
comparison
equal
deleted
inserted
replaced
846:bc982f1ad106 | 847:356e65836fb5 |
---|---|
2654 * Append to previous one for this token. | 2654 * Append to previous one for this token. |
2655 */ | 2655 */ |
2656 | 2656 |
2657 void Lexer::getDocComment(Token *t, unsigned lineComment) | 2657 void Lexer::getDocComment(Token *t, unsigned lineComment) |
2658 { | 2658 { |
2659 OutBuffer buf; | 2659 /* ct tells us which kind of comment it is: '/', '*', or '+' |
2660 */ | |
2660 unsigned char ct = t->ptr[2]; | 2661 unsigned char ct = t->ptr[2]; |
2662 | |
2663 /* Start of comment text skips over / * *, / + +, or / / / | |
2664 */ | |
2661 unsigned char *q = t->ptr + 3; // start of comment text | 2665 unsigned char *q = t->ptr + 3; // start of comment text |
2662 int linestart = 0; | |
2663 | 2666 |
2664 unsigned char *qend = p; | 2667 unsigned char *qend = p; |
2665 if (ct == '*' || ct == '+') | 2668 if (ct == '*' || ct == '+') |
2666 qend -= 2; | 2669 qend -= 2; |
2667 | 2670 |
2681 { | 2684 { |
2682 if (qend[-1] != ct) | 2685 if (qend[-1] != ct) |
2683 break; | 2686 break; |
2684 } | 2687 } |
2685 } | 2688 } |
2689 | |
2690 /* Comment is now [q .. qend]. | |
2691 * Canonicalize it into buf[]. | |
2692 */ | |
2693 OutBuffer buf; | |
2694 int linestart = 0; | |
2686 | 2695 |
2687 for (; q < qend; q++) | 2696 for (; q < qend; q++) |
2688 { | 2697 { |
2689 unsigned char c = *q; | 2698 unsigned char c = *q; |
2690 | 2699 |
2758 else | 2767 else |
2759 *dc = (unsigned char *)buf.extractData(); | 2768 *dc = (unsigned char *)buf.extractData(); |
2760 } | 2769 } |
2761 | 2770 |
2762 /******************************************** | 2771 /******************************************** |
2763 * Combine two document comments into one. | 2772 * Combine two document comments into one, |
2773 * separated by a newline. | |
2764 */ | 2774 */ |
2765 | 2775 |
2766 unsigned char *Lexer::combineComments(unsigned char *c1, unsigned char *c2) | 2776 unsigned char *Lexer::combineComments(unsigned char *c1, unsigned char *c2) |
2767 { | 2777 { |
2778 //printf("Lexer::combineComments('%s', '%s')\n", c1, c2); | |
2779 | |
2768 unsigned char *c = c2; | 2780 unsigned char *c = c2; |
2769 | 2781 |
2770 if (c1) | 2782 if (c1) |
2771 { c = c1; | 2783 { c = c1; |
2772 if (c2) | 2784 if (c2) |
2773 { size_t len1 = strlen((char *)c1); | 2785 { size_t len1 = strlen((char *)c1); |
2774 size_t len2 = strlen((char *)c2); | 2786 size_t len2 = strlen((char *)c2); |
2775 | 2787 |
2776 c = (unsigned char *)mem.malloc(len1 + 1 + len2 + 1); | 2788 c = (unsigned char *)mem.malloc(len1 + 1 + len2 + 1); |
2777 memcpy(c, c1, len1); | 2789 memcpy(c, c1, len1); |
2778 c[len1] = '\n'; | 2790 if (len1 && c1[len1 - 1] != '\n') |
2779 memcpy(c + len1 + 1, c2, len2); | 2791 { c[len1] = '\n'; |
2780 c[len1 + 1 + len2] = 0; | 2792 len1++; |
2793 } | |
2794 memcpy(c + len1, c2, len2); | |
2795 c[len1 + len2] = 0; | |
2781 } | 2796 } |
2782 } | 2797 } |
2783 return c; | 2798 return c; |
2784 } | 2799 } |
2785 | 2800 |
2910 { "import", TOKimport }, | 2925 { "import", TOKimport }, |
2911 { "mixin", TOKmixin }, | 2926 { "mixin", TOKmixin }, |
2912 { "static", TOKstatic }, | 2927 { "static", TOKstatic }, |
2913 { "final", TOKfinal }, | 2928 { "final", TOKfinal }, |
2914 { "const", TOKconst }, | 2929 { "const", TOKconst }, |
2915 { "immutable", TOKimmutable }, | |
2916 { "typedef", TOKtypedef }, | 2930 { "typedef", TOKtypedef }, |
2917 { "alias", TOKalias }, | 2931 { "alias", TOKalias }, |
2918 { "override", TOKoverride }, | 2932 { "override", TOKoverride }, |
2919 { "abstract", TOKabstract }, | 2933 { "abstract", TOKabstract }, |
2920 { "volatile", TOKvolatile }, | 2934 { "volatile", TOKvolatile }, |
2950 { "__traits", TOKtraits }, | 2964 { "__traits", TOKtraits }, |
2951 { "__overloadset", TOKoverloadset }, | 2965 { "__overloadset", TOKoverloadset }, |
2952 { "__FILE__", TOKfile }, | 2966 { "__FILE__", TOKfile }, |
2953 { "__LINE__", TOKline }, | 2967 { "__LINE__", TOKline }, |
2954 { "shared", TOKshared }, | 2968 { "shared", TOKshared }, |
2969 { "immutable", TOKimmutable }, | |
2955 #endif | 2970 #endif |
2956 }; | 2971 }; |
2957 | 2972 |
2958 int Token::isKeyword() | 2973 int Token::isKeyword() |
2959 { | 2974 { |