"Fossies" - the Fresh Open Source Software Archive

Member "dmd2/src/dmd/dmd/tokens.h" (20 Nov 2020, 6269 Bytes) of package /linux/misc/dmd.2.094.2.linux.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 /* Compiler implementation of the D programming language
    3  * Copyright (C) 1999-2020 by The D Language Foundation, All Rights Reserved
    4  * written by Walter Bright
    5  * http://www.digitalmars.com
    6  * Distributed under the Boost Software License, Version 1.0.
    7  * http://www.boost.org/LICENSE_1_0.txt
    8  * https://github.com/dlang/dmd/blob/master/src/dmd/tokens.h
    9  */
   10 
   11 #pragma once
   12 
   13 #include "root/dcompat.h"
   14 #include "root/port.h"
   15 #include "globals.h"
   16 
   17 class Identifier;
   18 
   19 /* Tokens:
   20         (       )
   21         [       ]
   22         {       }
   23         <       >       <=      >=      ==      !=      ===     !==
   24         <<      >>      <<=     >>=     >>>     >>>=
   25         +       -       +=      -=
   26         *       /       %       *=      /=      %=
   27         &       |       ^       &=      |=      ^=
   28         =       !       ~       @
   29         ^^      ^^=
   30         ++      --
   31         .       ->      :       ,       =>
   32         ?       &&      ||
   33  */
   34 
   35 typedef unsigned char TOK;
   36 enum
   37 {
   38         TOKreserved,
   39 
   40         // Other
   41         TOKlparen,      TOKrparen,
   42         TOKlbracket,    TOKrbracket,
   43         TOKlcurly,      TOKrcurly,
   44         TOKcolon,       TOKneg,
   45         TOKsemicolon,   TOKdotdotdot,
   46         TOKeof,         TOKcast,
   47         TOKnull,        TOKassert,
   48         TOKtrue,        TOKfalse,
   49         TOKarray,       TOKcall,
   50         TOKaddress,
   51         TOKtype,        TOKthrow,
   52         TOKnew,         TOKdelete,
   53         TOKstar,        TOKsymoff,
   54         TOKvar,         TOKdotvar,
   55         TOKdotid,       TOKdotti,
   56         TOKdottype,     TOKslice,
   57         TOKarraylength, TOKversion,
   58         TOKmodule,      TOKdollar,
   59         TOKtemplate,    TOKdottd,
   60         TOKdeclaration, TOKtypeof,
   61         TOKpragma,      TOKdsymbol,
   62         TOKtypeid,      TOKuadd,
   63         TOKremove,
   64         TOKnewanonclass, TOKcomment,
   65         TOKarrayliteral, TOKassocarrayliteral,
   66         TOKstructliteral,
   67         TOKclassreference,
   68         TOKthrownexception,
   69         TOKdelegateptr,
   70         TOKdelegatefuncptr,
   71 
   72 // 54
   73         // Operators
   74         TOKlt,          TOKgt,
   75         TOKle,          TOKge,
   76         TOKequal,       TOKnotequal,
   77         TOKidentity,    TOKnotidentity,
   78         TOKindex,       TOKis,
   79 
   80 // 64
   81         TOKshl,         TOKshr,
   82         TOKshlass,      TOKshrass,
   83         TOKushr,        TOKushrass,
   84         TOKcat,         TOKcatass,      TOKcatelemass,  TOKcatdcharass,     // ~ ~=
   85         TOKadd,         TOKmin,         TOKaddass,      TOKminass,
   86         TOKmul,         TOKdiv,         TOKmod,
   87         TOKmulass,      TOKdivass,      TOKmodass,
   88         TOKand,         TOKor,          TOKxor,
   89         TOKandass,      TOKorass,       TOKxorass,
   90         TOKassign,      TOKnot,         TOKtilde,
   91         TOKplusplus,    TOKminusminus,  TOKconstruct,   TOKblit,
   92         TOKdot,         TOKarrow,       TOKcomma,
   93         TOKquestion,    TOKandand,      TOKoror,
   94         TOKpreplusplus, TOKpreminusminus,
   95 
   96 // 105
   97         // Numeric literals
   98         TOKint32v, TOKuns32v,
   99         TOKint64v, TOKuns64v,
  100         TOKint128v, TOKuns128v,
  101         TOKfloat32v, TOKfloat64v, TOKfloat80v,
  102         TOKimaginary32v, TOKimaginary64v, TOKimaginary80v,
  103 
  104         // Char constants
  105         TOKcharv, TOKwcharv, TOKdcharv,
  106 
  107         // Leaf operators
  108         TOKidentifier,  TOKstring, TOKxstring,
  109         TOKthis,        TOKsuper,
  110         TOKhalt,        TOKtuple,
  111         TOKerror,
  112 
  113         // Basic types
  114         TOKvoid,
  115         TOKint8, TOKuns8,
  116         TOKint16, TOKuns16,
  117         TOKint32, TOKuns32,
  118         TOKint64, TOKuns64,
  119         TOKint128, TOKuns128,
  120         TOKfloat32, TOKfloat64, TOKfloat80,
  121         TOKimaginary32, TOKimaginary64, TOKimaginary80,
  122         TOKcomplex32, TOKcomplex64, TOKcomplex80,
  123         TOKchar, TOKwchar, TOKdchar, TOKbool,
  124 
  125 // 152
  126         // Aggregates
  127         TOKstruct, TOKclass, TOKinterface, TOKunion, TOKenum, TOKimport,
  128         TOKalias, TOKoverride, TOKdelegate, TOKfunction,
  129         TOKmixin,
  130 
  131         TOKalign, TOKextern, TOKprivate, TOKprotected, TOKpublic, TOKexport,
  132         TOKstatic, TOKfinal, TOKconst, TOKabstract,
  133         TOKdebug, TOKdeprecated, TOKin, TOKout, TOKinout, TOKlazy,
  134         TOKauto, TOKpackage, TOKimmutable,
  135 
  136 // 182
  137         // Statements
  138         TOKif, TOKelse, TOKwhile, TOKfor, TOKdo, TOKswitch,
  139         TOKcase, TOKdefault, TOKbreak, TOKcontinue, TOKwith,
  140         TOKsynchronized, TOKreturn, TOKgoto, TOKtry, TOKcatch, TOKfinally,
  141         TOKasm, TOKforeach, TOKforeach_reverse,
  142         TOKscope,
  143         TOKon_scope_exit, TOKon_scope_failure, TOKon_scope_success,
  144 
  145 // 206
  146         // Contracts
  147         TOKinvariant,
  148 
  149         // Testing
  150         TOKunittest,
  151 
  152         // Added after 1.0
  153         TOKargTypes,
  154         TOKref,
  155         TOKmacro,
  156 
  157 // 211
  158         TOKparameters,
  159         TOKtraits,
  160         TOKoverloadset,
  161         TOKpure,
  162         TOKnothrow,
  163         TOKgshared,
  164         TOKline,
  165         TOKfile,
  166         TOKfilefullpath,
  167         TOKmodulestring,
  168         TOKfuncstring,
  169         TOKprettyfunc,
  170         TOKshared,
  171         TOKat,
  172         TOKpow,
  173         TOKpowass,
  174         TOKgoesto,
  175         TOKvector,
  176         TOKpound,
  177 
  178 // 230
  179         TOKinterval,
  180         TOKvoidexp,
  181         TOKcantexp,
  182         TOKshowctfecontext,
  183 
  184         TOKobjc_class_reference,
  185         TOKvectorarray,
  186 
  187         TOKMAX
  188 };
  189 
  190 #define TOKwild TOKinout
  191 
  192 // Token has an anonymous struct, which is not strict ISO C++.
  193 #if defined(__GNUC__)
  194 #pragma GCC diagnostic push
  195 #pragma GCC diagnostic ignored "-Wpedantic"
  196 #endif
  197 
  198 struct Token
  199 {
  200     Token *next;
  201     Loc loc;
  202     const utf8_t *ptr;    // pointer to first character of this token within buffer
  203     TOK value;
  204     DString blockComment; // doc comment string prior to this token
  205     DString lineComment;  // doc comment for previous token
  206     union
  207     {
  208         // Integers
  209         sinteger_t intvalue;
  210         uinteger_t unsvalue;
  211 
  212         // Floats
  213         real_t floatvalue;
  214 
  215         struct
  216         {   utf8_t *ustring;     // UTF8 string
  217             unsigned len;
  218             unsigned char postfix;      // 'c', 'w', 'd'
  219         };
  220 
  221         Identifier *ident;
  222     };
  223 
  224     void free();
  225 
  226     Token() : next(NULL) {}
  227     int isKeyword();
  228     const char *toChars() const;
  229 
  230     static const char *toChars(unsigned char value);
  231 };
  232 
  233 #if defined(__GNUC__)
  234 #pragma GCC diagnostic pop
  235 #endif