Mercurial > projects > ldc
comparison dmd/lexer.c @ 1195:e961851fb8be
Merged DMD 1.042.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Fri, 03 Apr 2009 17:59:34 +0200 |
parents | 226c07c71967 |
children | 79758fd2f48a |
comparison
equal
deleted
inserted
replaced
1194:1853dcd9b944 | 1195:e961851fb8be |
---|---|
1 | 1 |
2 // Compiler implementation of the D programming language | 2 // Compiler implementation of the D programming language |
3 // Copyright (c) 1999-2008 by Digital Mars | 3 // Copyright (c) 1999-2009 by Digital Mars |
4 // All Rights Reserved | 4 // All Rights Reserved |
5 // written by Walter Bright | 5 // written by Walter Bright |
6 // http://www.digitalmars.com | 6 // http://www.digitalmars.com |
7 // License for redistribution is by either the Artistic License | 7 // License for redistribution is by either the Artistic License |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | 8 // in artistic.txt, or the GNU General Public License in gnu.txt. |
9 // See the included readme.txt for details. | 9 // See the included readme.txt for details. |
10 | 10 |
11 #define __C99FEATURES__ 1 | 11 #include <cmath> |
12 | 12 |
13 /* Lexical Analyzer */ | 13 /* Lexical Analyzer */ |
14 | 14 |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 #include <string.h> | 16 #include <string.h> |
18 #include <stdarg.h> | 18 #include <stdarg.h> |
19 #include <errno.h> | 19 #include <errno.h> |
20 #include <wchar.h> | 20 #include <wchar.h> |
21 #include <stdlib.h> | 21 #include <stdlib.h> |
22 #include <assert.h> | 22 #include <assert.h> |
23 #include <math.h> | 23 #include <time.h> // for time() and ctime() |
24 | |
25 #if _MSC_VER | |
26 #include <time.h> | |
27 #else | |
28 #include <sys/time.h> | |
29 #endif | |
30 | |
31 #ifdef IN_GCC | |
32 #include <time.h> | |
33 #elif __GNUC__ | |
34 #include <time.h> | |
35 #endif | |
36 | 24 |
37 #include "rmem.h" | 25 #include "rmem.h" |
38 | 26 |
39 #include "stringtable.h" | 27 #include "stringtable.h" |
40 | 28 |
45 #include "module.h" | 33 #include "module.h" |
46 | 34 |
47 #if _WIN32 && __DMC__ | 35 #if _WIN32 && __DMC__ |
48 // from \dm\src\include\setlocal.h | 36 // from \dm\src\include\setlocal.h |
49 extern "C" char * __cdecl __locale_decpoint; | 37 extern "C" char * __cdecl __locale_decpoint; |
50 #endif | |
51 | |
52 #if _MSC_VER // workaround VC++ bug, labels and types should be in separate namespaces | |
53 #define Lstring Lstr | |
54 #endif | 38 #endif |
55 | 39 |
56 extern int HtmlNamedEntity(unsigned char *p, int length); | 40 extern int HtmlNamedEntity(unsigned char *p, int length); |
57 | 41 |
58 #define LS 0x2028 // UTF line separator | 42 #define LS 0x2028 // UTF line separator |
680 | 664 |
681 #if DMDV1 | 665 #if DMDV1 |
682 if (mod && id == Id::FILE) | 666 if (mod && id == Id::FILE) |
683 { | 667 { |
684 t->ustring = (unsigned char *)(loc.filename ? loc.filename : mod->ident->toChars()); | 668 t->ustring = (unsigned char *)(loc.filename ? loc.filename : mod->ident->toChars()); |
685 goto Lstring; | 669 goto Lstr; |
686 } | 670 } |
687 else if (mod && id == Id::LINE) | 671 else if (mod && id == Id::LINE) |
688 { | 672 { |
689 t->value = TOKint64v; | 673 t->value = TOKint64v; |
690 t->uns64value = loc.linnum; | 674 t->uns64value = loc.linnum; |
692 else | 676 else |
693 #endif | 677 #endif |
694 if (id == Id::DATE) | 678 if (id == Id::DATE) |
695 { | 679 { |
696 t->ustring = (unsigned char *)date; | 680 t->ustring = (unsigned char *)date; |
697 goto Lstring; | 681 goto Lstr; |
698 } | 682 } |
699 else if (id == Id::TIME) | 683 else if (id == Id::TIME) |
700 { | 684 { |
701 t->ustring = (unsigned char *)time; | 685 t->ustring = (unsigned char *)time; |
702 goto Lstring; | 686 goto Lstr; |
703 } | 687 } |
704 else if (id == Id::VENDOR) | 688 else if (id == Id::VENDOR) |
705 { | 689 { |
706 t->ustring = (unsigned char *)"LDC"; | 690 t->ustring = (unsigned char *)"LDC"; |
707 goto Lstring; | 691 goto Lstr; |
708 } | 692 } |
709 else if (id == Id::TIMESTAMP) | 693 else if (id == Id::TIMESTAMP) |
710 { | 694 { |
711 t->ustring = (unsigned char *)timestamp; | 695 t->ustring = (unsigned char *)timestamp; |
712 Lstring: | 696 Lstr: |
713 t->value = TOKstring; | 697 t->value = TOKstring; |
714 Llen: | 698 Llen: |
715 t->postfix = 0; | 699 t->postfix = 0; |
716 t->len = strlen((char *)t->ustring); | 700 t->len = strlen((char *)t->ustring); |
717 } | 701 } |
3095 Token::tochars[TOKdsymbol] = "symbol"; | 3079 Token::tochars[TOKdsymbol] = "symbol"; |
3096 Token::tochars[TOKtuple] = "tuple"; | 3080 Token::tochars[TOKtuple] = "tuple"; |
3097 Token::tochars[TOKdeclaration] = "declaration"; | 3081 Token::tochars[TOKdeclaration] = "declaration"; |
3098 Token::tochars[TOKdottd] = "dottd"; | 3082 Token::tochars[TOKdottd] = "dottd"; |
3099 Token::tochars[TOKon_scope_exit] = "scope(exit)"; | 3083 Token::tochars[TOKon_scope_exit] = "scope(exit)"; |
3100 } | 3084 Token::tochars[TOKon_scope_success] = "scope(success)"; |
3085 Token::tochars[TOKon_scope_failure] = "scope(failure)"; | |
3086 } |