LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2LexBuf.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 46.6 % 656 306
Test Date: 2026-02-28 14:20:25 Functions: 75.5 % 53 40
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* do not edit automatically generated by mc from M2LexBuf.  */
       2              : /* M2LexBuf.mod provides a buffer for m2.lex.
       3              : 
       4              : Copyright (C) 2001-2026 Free Software Foundation, Inc.
       5              : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6              : 
       7              : This file is part of GNU Modula-2.
       8              : 
       9              : GNU Modula-2 is free software; you can redistribute it and/or modify
      10              : it under the terms of the GNU General Public License as published by
      11              : the Free Software Foundation; either version 3, or (at your option)
      12              : any later version.
      13              : 
      14              : GNU Modula-2 is distributed in the hope that it will be useful, but
      15              : WITHOUT ANY WARRANTY; without even the implied warranty of
      16              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17              : General Public License for more details.
      18              : 
      19              : You should have received a copy of the GNU General Public License
      20              : along with GNU Modula-2; see the file COPYING3.  If not see
      21              : <http://www.gnu.org/licenses/>.  */
      22              : 
      23              : #include "config.h"
      24              : #include "system.h"
      25              : #include "gcc-consolidation.h"
      26              : 
      27              : #include <stdbool.h>
      28              : #   if !defined (PROC_D)
      29              : #      define PROC_D
      30              :        typedef void (*PROC_t) (void);
      31              :        typedef struct { PROC_t proc; } PROC;
      32              : #   endif
      33              : 
      34              : #   if !defined (TRUE)
      35              : #      define TRUE (1==1)
      36              : #   endif
      37              : 
      38              : #   if !defined (FALSE)
      39              : #      define FALSE (1==0)
      40              : #   endif
      41              : 
      42              : #   include "GStorage.h"
      43              : #if defined(__cplusplus)
      44              : #   undef NULL
      45              : #   define NULL 0
      46              : #endif
      47              : #define _M2LexBuf_C
      48              : 
      49              : #include "GM2LexBuf.h"
      50              : #   include "Gm2flex.h"
      51              : #   include "GFIO.h"
      52              : #   include "Glibc.h"
      53              : #   include "GSYSTEM.h"
      54              : #   include "GStorage.h"
      55              : #   include "GDynamicStrings.h"
      56              : #   include "GFormatStrings.h"
      57              : #   include "GNameKey.h"
      58              : #   include "GM2Reserved.h"
      59              : #   include "GM2Printf.h"
      60              : #   include "GM2Debug.h"
      61              : #   include "GNumberIO.h"
      62              : #   include "Ggcctypes.h"
      63              : #   include "Gm2linemap.h"
      64              : #   include "GM2Emit.h"
      65              : #   include "GM2Error.h"
      66              : #   include "GM2MetaError.h"
      67              : #   include "GM2Options.h"
      68              : #   include "GM2LangDump.h"
      69              : #   include "GIndexing.h"
      70              : #   include "GM2RTS.h"
      71              : 
      72              : #   define M2LexBuf_UnknownTokenNo 0
      73              : #   define M2LexBuf_BuiltinTokenNo 1
      74              : #   define Tracing false
      75              : #   define Debugging false
      76              : #   define DebugRecover false
      77              : #   define BadTokenNo 32579
      78              : #   define InitialSourceToken 2
      79              : typedef struct M2LexBuf__T1_r M2LexBuf__T1;
      80              : 
      81              : typedef M2LexBuf__T1 *M2LexBuf_SourceList;
      82              : 
      83              : typedef struct M2LexBuf__T2_r M2LexBuf__T2;
      84              : 
      85              : typedef M2LexBuf__T2 *M2LexBuf_TokenDesc;
      86              : 
      87              : struct M2LexBuf__T1_r {
      88              :                         M2LexBuf_SourceList left;
      89              :                         M2LexBuf_SourceList right;
      90              :                         DynamicStrings_String name;
      91              :                         unsigned int line;
      92              :                         unsigned int col;
      93              :                       };
      94              : 
      95              : struct M2LexBuf__T2_r {
      96              :                         M2Reserved_toktype token;
      97              :                         NameKey_Name str;
      98              :                         int int_;
      99              :                         unsigned int line;
     100              :                         unsigned int col;
     101              :                         M2LexBuf_SourceList file;
     102              :                         location_t loc;
     103              :                         Indexing_Index insert;
     104              :                       };
     105              : 
     106              : static M2LexBuf_SourceList CurrentSource;
     107              : static bool UseBufferedTokens;
     108              : static bool CurrentUsed;
     109              : static Indexing_Index ListOfTokens;
     110              : static unsigned int CurrentTokNo;
     111              : static unsigned int InsertionIndex;
     112              : static bool SeenEof;
     113              : static unsigned int indent;
     114              : 
     115              : /*
     116              :    OpenSource - Attempts to open the source file, s.
     117              :                 The success of the operation is returned.
     118              : */
     119              : 
     120              : extern "C" bool M2LexBuf_OpenSource (DynamicStrings_String s);
     121              : 
     122              : /*
     123              :    CloseSource - closes the current open file.
     124              : */
     125              : 
     126              : extern "C" void M2LexBuf_CloseSource (void);
     127              : 
     128              : /*
     129              :    ReInitialize - re-initialize the all the data structures.
     130              : */
     131              : 
     132              : extern "C" void M2LexBuf_ReInitialize (void);
     133              : 
     134              : /*
     135              :    ResetForNewPass - reset the buffer pointers to the beginning ready for
     136              :                      a new pass
     137              : */
     138              : 
     139              : extern "C" void M2LexBuf_ResetForNewPass (void);
     140              : 
     141              : /*
     142              :    GetToken - gets the next token into currenttoken.
     143              : */
     144              : 
     145              : extern "C" void M2LexBuf_GetToken (void);
     146              : 
     147              : /*
     148              :    InsertToken - inserts a symbol token infront of the current token
     149              :                  ready for the next pass.
     150              : */
     151              : 
     152              : extern "C" void M2LexBuf_InsertToken (M2Reserved_toktype token);
     153              : 
     154              : /*
     155              :    InsertTokenAndRewind - inserts a symbol token infront of the current token
     156              :                           and then moves the token stream back onto the inserted
     157              :                           token.
     158              : */
     159              : 
     160              : extern "C" void M2LexBuf_InsertTokenAndRewind (M2Reserved_toktype token);
     161              : 
     162              : /*
     163              :    GetPreviousTokenLineNo - returns the line number of the previous token.
     164              : */
     165              : 
     166              : extern "C" unsigned int M2LexBuf_GetPreviousTokenLineNo (void);
     167              : 
     168              : /*
     169              :    GetLineNo - returns the current line number where the symbol occurs in
     170              :                the source file.
     171              : */
     172              : 
     173              : extern "C" unsigned int M2LexBuf_GetLineNo (void);
     174              : 
     175              : /*
     176              :    GetTokenNo - returns the current token number.
     177              : */
     178              : 
     179              : extern "C" unsigned int M2LexBuf_GetTokenNo (void);
     180              : 
     181              : /*
     182              :    GetTokenName - returns the token name given the tokenno.
     183              : */
     184              : 
     185              : extern "C" NameKey_Name M2LexBuf_GetTokenName (unsigned int tokenno);
     186              : 
     187              : /*
     188              :    TokenToLineNo - returns the line number of the current file for the
     189              :                    tokenno. The depth refers to the include depth.
     190              :                    A depth of 0 is the current file, depth of 1 is the file
     191              :                    which included the current file. Zero is returned if the
     192              :                    depth exceeds the file nesting level.
     193              : */
     194              : 
     195              : extern "C" unsigned int M2LexBuf_TokenToLineNo (unsigned int tokenno, unsigned int depth);
     196              : 
     197              : /*
     198              :    GetColumnNo - returns the current column where the symbol occurs in
     199              :                  the source file.
     200              : */
     201              : 
     202              : extern "C" unsigned int M2LexBuf_GetColumnNo (void);
     203              : 
     204              : /*
     205              :    TokenToColumnNo - returns the column number of the current file for the
     206              :                      tokenno. The depth refers to the include depth.
     207              :                      A depth of 0 is the current file, depth of 1 is the file
     208              :                      which included the current file. Zero is returned if the
     209              :                      depth exceeds the file nesting level.
     210              : */
     211              : 
     212              : extern "C" unsigned int M2LexBuf_TokenToColumnNo (unsigned int tokenno, unsigned int depth);
     213              : 
     214              : /*
     215              :    TokenToLocation - returns the location_t corresponding to tokenno.
     216              : */
     217              : 
     218              : extern "C" location_t M2LexBuf_TokenToLocation (unsigned int tokenno);
     219              : 
     220              : /*
     221              :    FindFileNameFromToken - returns the complete FileName for the appropriate
     222              :                            source file yields the token number, TokenNo.
     223              :                            The, Depth, indicates the include level: 0..n
     224              :                            Level 0 is the current. NIL is returned if n+1
     225              :                            is requested.
     226              : */
     227              : 
     228              : extern "C" DynamicStrings_String M2LexBuf_FindFileNameFromToken (unsigned int tokenno, unsigned int depth);
     229              : 
     230              : /*
     231              :    GetFileName - returns a String defining the current file.
     232              : */
     233              : 
     234              : extern "C" DynamicStrings_String M2LexBuf_GetFileName (void);
     235              : 
     236              : /*
     237              :    MakeVirtualTok - providing caret, left, right are associated with a source file
     238              :                     and exist on the same src line then
     239              :                     create and return a new tokenno which is created from
     240              :                     tokenno left and right.  Otherwise return caret.
     241              :                     If caret is UnknownTokenNo then it is replaced with left or right
     242              :                     in sequence to avoid an UnknownTokenNo.
     243              : */
     244              : 
     245              : extern "C" unsigned int M2LexBuf_MakeVirtualTok (unsigned int caret, unsigned int left, unsigned int right);
     246              : 
     247              : /*
     248              :    MakeVirtual2Tok - creates and return a new tokenno which is created from
     249              :                      two tokens left and right.  It tries to avoid UnknownTokenNo
     250              :                      and will fall back to left or right if necessary.
     251              : */
     252              : 
     253              : extern "C" unsigned int M2LexBuf_MakeVirtual2Tok (unsigned int left, unsigned int right);
     254              : 
     255              : /*
     256              :    AddTok - adds a token to the buffer.
     257              : */
     258              : 
     259              : extern "C" void M2LexBuf_AddTok (M2Reserved_toktype t);
     260              : 
     261              : /*
     262              :    AddTokCharStar - adds a token to the buffer and an additional string, s.
     263              :                     A copy of string, s, is made.
     264              : */
     265              : 
     266              : extern "C" void M2LexBuf_AddTokCharStar (M2Reserved_toktype t, void * s);
     267              : 
     268              : /*
     269              :    AddTokInteger - adds a token and an integer to the buffer.
     270              : */
     271              : 
     272              : extern "C" void M2LexBuf_AddTokInteger (M2Reserved_toktype t, int i);
     273              : 
     274              : /*
     275              :    SetFile - sets the current filename to, filename.
     276              : */
     277              : 
     278              : extern "C" void M2LexBuf_SetFile (void * filename);
     279              : 
     280              : /*
     281              :    PushFile - indicates that, filename, has just been included.
     282              : */
     283              : 
     284              : extern "C" void M2LexBuf_PushFile (void * filename);
     285              : 
     286              : /*
     287              :    PopFile - indicates that we are returning to, filename, having finished
     288              :              an include.
     289              : */
     290              : 
     291              : extern "C" void M2LexBuf_PopFile (void * filename);
     292              : 
     293              : /*
     294              :    PrintTokenNo - displays token and the location of the token.
     295              : */
     296              : 
     297              : extern "C" void M2LexBuf_PrintTokenNo (unsigned int tokenno);
     298              : 
     299              : /*
     300              :    DisplayToken - display the token name using printf0 no newline is emitted.
     301              : */
     302              : 
     303              : extern "C" void M2LexBuf_DisplayToken (M2Reserved_toktype tok);
     304              : 
     305              : /*
     306              :    DumpTokens - displays all tokens.
     307              : */
     308              : 
     309              : extern "C" void M2LexBuf_DumpTokens (void);
     310              : static void stop (void);
     311              : 
     312              : /*
     313              :    InitTokenDesc - returns a TokenDesc filled in with the parameters and
     314              :                    the insert field set to NIL.
     315              : */
     316              : 
     317              : static M2LexBuf_TokenDesc InitTokenDesc (M2Reserved_toktype token, NameKey_Name str, int int_, unsigned int line, unsigned int col, M2LexBuf_SourceList file, location_t loc);
     318              : 
     319              : /*
     320              :    DeleteTokenDesc - delete tokdesc and any sub indices.
     321              : */
     322              : 
     323              : static void DeleteTokenDesc (M2LexBuf_TokenDesc tokdesc);
     324              : 
     325              : /*
     326              :    Append - appends tokdesc to the end of the list defined by index.
     327              : */
     328              : 
     329              : static void Append (Indexing_Index index, M2LexBuf_TokenDesc tokdesc);
     330              : 
     331              : /*
     332              :    InitTokenList - creates an empty token list, which starts the first source token
     333              :                    at position 2.  This allows position 0 to be used for the unknown
     334              :                    location and position 1 for the builtin token.
     335              : */
     336              : 
     337              : static void InitTokenList (void);
     338              : 
     339              : /*
     340              :    Init - initializes the token list and source list.
     341              : */
     342              : 
     343              : static void Init (void);
     344              : 
     345              : /*
     346              :    AddTo - adds a new element to the end of SourceList, CurrentSource.
     347              : */
     348              : 
     349              : static void AddTo (M2LexBuf_SourceList l);
     350              : 
     351              : /*
     352              :    SubFrom - subtracts, l, from the source list.
     353              : */
     354              : 
     355              : static void SubFrom (M2LexBuf_SourceList l);
     356              : 
     357              : /*
     358              :    NewElement - returns a new SourceList
     359              : */
     360              : 
     361              : static M2LexBuf_SourceList NewElement (void * s);
     362              : 
     363              : /*
     364              :    NewList - initializes an empty list with the classic dummy header element.
     365              : */
     366              : 
     367              : static M2LexBuf_SourceList NewList (void);
     368              : 
     369              : /*
     370              :    CheckIfNeedToDuplicate - checks to see whether the CurrentSource has
     371              :                             been used, if it has then duplicate the list.
     372              : */
     373              : 
     374              : static void CheckIfNeedToDuplicate (void);
     375              : 
     376              : /*
     377              :    KillList - kills the SourceList providing that it has not been used.
     378              : */
     379              : 
     380              : static void KillList (void);
     381              : 
     382              : /*
     383              :    DumpToken -
     384              : */
     385              : 
     386              : static void DumpToken (M2LexBuf_TokenDesc tokdesc);
     387              : 
     388              : /*
     389              :    CopyOutCurrent - copies the token in buffer[index][insertion] into
     390              :                     then current token global variables.
     391              : */
     392              : 
     393              : static void CopyOutCurrent (Indexing_Index buffer, unsigned int index, unsigned int insertion);
     394              : 
     395              : /*
     396              :    UpdateToken - update the global current token variables from buffer[index]
     397              :                  using inserted tokens if directed by InsertionIndex.
     398              : */
     399              : 
     400              : static void UpdateToken (Indexing_Index buffer, unsigned int index);
     401              : 
     402              : /*
     403              :    GetTokenFiltered - providing that we have not already seen an eof for this source
     404              :                       file call m2flex.GetToken and GetToken if requested.
     405              : */
     406              : 
     407              : static void GetTokenFiltered (bool callGetToken);
     408              : 
     409              : /*
     410              :    AppendInsertToken -
     411              : */
     412              : 
     413              : static void AppendInsertToken (Indexing_Index index, M2LexBuf_TokenDesc tokdesc);
     414              : 
     415              : /*
     416              :    DupTok - duplicate tokdesc and replaces the token field with token.
     417              : */
     418              : 
     419              : static M2LexBuf_TokenDesc DupTok (M2LexBuf_TokenDesc tokdesc, M2Reserved_toktype token);
     420              : 
     421              : /*
     422              :    AddTokToList - adds a token to a dynamic list.
     423              : */
     424              : 
     425              : static void AddTokToList (M2Reserved_toktype token, NameKey_Name str, int int_, unsigned int line, unsigned int col, M2LexBuf_SourceList file, location_t location);
     426              : 
     427              : /*
     428              :    IsLastTokenEof - returns TRUE if the last token was an eoftok
     429              : */
     430              : 
     431              : static bool IsLastTokenEof (void);
     432              : 
     433              : /*
     434              :    isSrcToken - returns TRUE if tokenno is associated with
     435              :                 program source code.
     436              : */
     437              : 
     438              : static bool isSrcToken (unsigned int tokenno);
     439              : 
     440              : /*
     441              :    tprintf0 -
     442              : */
     443              : 
     444              : static void tprintf0 (const char *format_, unsigned int _format_high);
     445              : 
     446              : /*
     447              :    tprintf1 -
     448              : */
     449              : 
     450              : static void tprintf1 (const char *format_, unsigned int _format_high, DynamicStrings_String str);
     451              : 
     452            0 : static void stop (void)
     453              : {
     454            0 : }
     455              : 
     456              : 
     457              : /*
     458              :    InitTokenDesc - returns a TokenDesc filled in with the parameters and
     459              :                    the insert field set to NIL.
     460              : */
     461              : 
     462    204568828 : static M2LexBuf_TokenDesc InitTokenDesc (M2Reserved_toktype token, NameKey_Name str, int int_, unsigned int line, unsigned int col, M2LexBuf_SourceList file, location_t loc)
     463              : {
     464    204568828 :   M2LexBuf_TokenDesc tokdesc;
     465              : 
     466            0 :   Storage_ALLOCATE ((void **) &tokdesc, sizeof (M2LexBuf__T2));
     467    204568828 :   tokdesc->token = token;
     468    204568828 :   tokdesc->str = str;
     469    204568828 :   tokdesc->int_ = int_;
     470    204568828 :   tokdesc->line = line;
     471    204568828 :   tokdesc->col = col;
     472    204568828 :   tokdesc->file = file;
     473    204568828 :   tokdesc->loc = loc;
     474    204568828 :   tokdesc->insert = static_cast<Indexing_Index> (NULL);
     475    204568828 :   return tokdesc;
     476              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     477              :   __builtin_unreachable ();
     478              : }
     479              : 
     480              : 
     481              : /*
     482              :    DeleteTokenDesc - delete tokdesc and any sub indices.
     483              : */
     484              : 
     485        77804 : static void DeleteTokenDesc (M2LexBuf_TokenDesc tokdesc)
     486              : {
     487        77804 :   if (tokdesc->insert != NULL)
     488              :     {
     489            0 :       Indexing_ForeachIndiceInIndexDo (tokdesc->insert, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) DeleteTokenDesc});
     490              :     }
     491        77804 :   Storage_DEALLOCATE ((void **) &tokdesc, sizeof (M2LexBuf__T2));
     492        77804 : }
     493              : 
     494              : 
     495              : /*
     496              :    Append - appends tokdesc to the end of the list defined by index.
     497              : */
     498              : 
     499    204568828 : static void Append (Indexing_Index index, M2LexBuf_TokenDesc tokdesc)
     500              : {
     501    204568828 :   if (Indexing_IsEmpty (index))
     502              :     {
     503        29897 :       Indexing_PutIndice (index, Indexing_LowIndice (index), reinterpret_cast <void *> (tokdesc));
     504              :     }
     505              :   else
     506              :     {
     507    204538931 :       Indexing_PutIndice (index, (Indexing_HighIndice (index))+1, reinterpret_cast <void *> (tokdesc));
     508              :     }
     509    204568828 : }
     510              : 
     511              : 
     512              : /*
     513              :    InitTokenList - creates an empty token list, which starts the first source token
     514              :                    at position 2.  This allows position 0 to be used for the unknown
     515              :                    location and position 1 for the builtin token.
     516              : */
     517              : 
     518        29897 : static void InitTokenList (void)
     519              : {
     520              :   /* 65K elements in the array and when it becomes full it will grow to 1M, 16M etc elements.  */
     521        29897 :   ListOfTokens = Indexing_InitIndexTuned (0, (1024*1024) / 16, 16);
     522        29897 :   Append (ListOfTokens, InitTokenDesc (M2Reserved_eoftok, NameKey_NulName, 0, 0, 0, NULL, M2Emit_UnknownLocation ()));
     523        29897 :   Append (ListOfTokens, InitTokenDesc (M2Reserved_eoftok, NameKey_NulName, 0, 0, 0, NULL, M2Emit_BuiltinsLocation ()));
     524        29897 : }
     525              : 
     526              : 
     527              : /*
     528              :    Init - initializes the token list and source list.
     529              : */
     530              : 
     531        29897 : static void Init (void)
     532              : {
     533        29897 :   SeenEof = false;
     534        29897 :   InsertionIndex = 0;
     535        29897 :   M2LexBuf_currenttoken = M2Reserved_eoftok;
     536        29897 :   CurrentTokNo = InitialSourceToken;
     537        29897 :   CurrentSource = NULL;
     538        29897 :   UseBufferedTokens = false;
     539        29897 :   InitTokenList ();
     540        29897 : }
     541              : 
     542              : 
     543              : /*
     544              :    AddTo - adds a new element to the end of SourceList, CurrentSource.
     545              : */
     546              : 
     547       292144 : static void AddTo (M2LexBuf_SourceList l)
     548              : {
     549       292144 :   l->right = CurrentSource;
     550       292144 :   l->left = CurrentSource->left;
     551       292144 :   CurrentSource->left->right = l;
     552       292144 :   CurrentSource->left = l;
     553       292144 :   l->left->line = m2flex_GetLineNo ();
     554       292144 :   l->left->col = m2flex_GetColumnNo ();
     555       292144 : }
     556              : 
     557              : 
     558              : /*
     559              :    SubFrom - subtracts, l, from the source list.
     560              : */
     561              : 
     562            0 : static void SubFrom (M2LexBuf_SourceList l)
     563              : {
     564            0 :   l->left->right = l->right;
     565            0 :   l->right->left = l->left;
     566            0 : }
     567              : 
     568              : 
     569              : /*
     570              :    NewElement - returns a new SourceList
     571              : */
     572              : 
     573       292144 : static M2LexBuf_SourceList NewElement (void * s)
     574              : {
     575       292144 :   M2LexBuf_SourceList l;
     576              : 
     577       292144 :   Storage_ALLOCATE ((void **) &l, sizeof (M2LexBuf__T1));
     578       292144 :   if (l == NULL)
     579              :     {
     580            0 :       M2RTS_HALT (-1);
     581              :       __builtin_unreachable ();
     582              :     }
     583              :   else
     584              :     {
     585       292144 :       l->name = DynamicStrings_InitStringCharStar (s);
     586       292144 :       l->left = NULL;
     587       292144 :       l->right = NULL;
     588              :     }
     589       292144 :   return l;
     590              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     591              :   __builtin_unreachable ();
     592              : }
     593              : 
     594              : 
     595              : /*
     596              :    NewList - initializes an empty list with the classic dummy header element.
     597              : */
     598              : 
     599       292144 : static M2LexBuf_SourceList NewList (void)
     600              : {
     601       292144 :   M2LexBuf_SourceList l;
     602              : 
     603       292144 :   Storage_ALLOCATE ((void **) &l, sizeof (M2LexBuf__T1));
     604       292144 :   l->left = l;
     605       292144 :   l->right = l;
     606       292144 :   l->name = static_cast<DynamicStrings_String> (NULL);
     607       292144 :   return l;
     608              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     609              :   __builtin_unreachable ();
     610              : }
     611              : 
     612              : 
     613              : /*
     614              :    CheckIfNeedToDuplicate - checks to see whether the CurrentSource has
     615              :                             been used, if it has then duplicate the list.
     616              : */
     617              : 
     618            0 : static void CheckIfNeedToDuplicate (void)
     619              : {
     620            0 :   M2LexBuf_SourceList l;
     621            0 :   M2LexBuf_SourceList h;
     622              : 
     623            0 :   if (CurrentUsed)
     624              :     {
     625            0 :       l = CurrentSource->right;
     626            0 :       h = CurrentSource;
     627            0 :       CurrentSource = NewList ();
     628            0 :       while (l != h)
     629              :         {
     630            0 :           AddTo (NewElement (reinterpret_cast <void *> (l->name)));
     631            0 :           l = l->right;
     632              :         }
     633              :     }
     634            0 : }
     635              : 
     636              : 
     637              : /*
     638              :    KillList - kills the SourceList providing that it has not been used.
     639              : */
     640              : 
     641       307089 : static void KillList (void)
     642              : {
     643       307089 :   M2LexBuf_SourceList l;
     644       307089 :   M2LexBuf_SourceList k;
     645              : 
     646       307089 :   if (! CurrentUsed && (CurrentSource != NULL))
     647              :     {
     648              :       l = CurrentSource;
     649        93450 :       do {
     650        93450 :         k = l;
     651        93450 :         l = l->right;
     652        93450 :         Storage_DEALLOCATE ((void **) &k, sizeof (M2LexBuf__T1));
     653        93450 :       } while (! (l == CurrentSource));
     654              :     }
     655       307089 : }
     656              : 
     657              : 
     658              : /*
     659              :    DumpToken -
     660              : */
     661              : 
     662            0 : static void DumpToken (M2LexBuf_TokenDesc tokdesc)
     663              : {
     664            0 :   unsigned int n;
     665              : 
     666            0 :   n = indent;
     667            0 :   while (n > 0)
     668              :     {
     669            0 :       M2Printf_printf0 ((const char *) " ", 1);
     670            0 :       n -= 1;
     671              :     }
     672            0 :   M2LexBuf_DisplayToken (tokdesc->token);
     673            0 :   if (tokdesc->str != NameKey_NulName)
     674              :     {
     675            0 :       M2Printf_printf1 ((const char *) " %a", 3, (const unsigned char *) &tokdesc->str, (sizeof (tokdesc->str)-1));
     676              :     }
     677            0 :   if (tokdesc->insert != NULL)
     678              :     {
     679            0 :       M2Printf_printf0 ((const char *) "inserted error recovery tokens\\n", 32);
     680            0 :       indent += 2;
     681            0 :       Indexing_ForeachIndiceInIndexDo (tokdesc->insert, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) DumpToken});
     682            0 :       indent -= 2;
     683              :     }
     684            0 : }
     685              : 
     686              : 
     687              : /*
     688              :    CopyOutCurrent - copies the token in buffer[index][insertion] into
     689              :                     then current token global variables.
     690              : */
     691              : 
     692    958197196 : static void CopyOutCurrent (Indexing_Index buffer, unsigned int index, unsigned int insertion)
     693              : {
     694    958197196 :   M2LexBuf_TokenDesc tokdesc;
     695              : 
     696    958197196 :   tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (buffer, index));
     697    958197196 :   if (insertion != 0)
     698              :     {
     699           48 :       tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (tokdesc->insert, insertion));
     700              :     }
     701    958197196 :   M2LexBuf_currenttoken = tokdesc->token;
     702    958197196 :   M2LexBuf_currentstring = NameKey_KeyToCharStar (tokdesc->str);
     703    958197196 :   M2LexBuf_currentcolumn = tokdesc->col;
     704    958197196 :   M2LexBuf_currentinteger = tokdesc->int_;
     705    958197196 : }
     706              : 
     707              : 
     708              : /*
     709              :    UpdateToken - update the global current token variables from buffer[index]
     710              :                  using inserted tokens if directed by InsertionIndex.
     711              : */
     712              : 
     713    958197196 : static void UpdateToken (Indexing_Index buffer, unsigned int index)
     714              : {
     715    958197196 :   M2LexBuf_TokenDesc tokdesc;
     716              : 
     717    958197196 :   tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (buffer, index));
     718    958197196 :   if (InsertionIndex > 0)
     719              :     {
     720              :       /* avoid dangling else.  */
     721              :       /* We have an inserted token to use.  */
     722           48 :       M2Debug_Assert (tokdesc->insert != NULL);
     723           48 :       CopyOutCurrent (buffer, index, InsertionIndex);
     724              :       /* Move InsertionIndex to the next position.  */
     725           48 :       InsertionIndex += 1;
     726           48 :       if (InsertionIndex > (Indexing_HighIndice (tokdesc->insert)))
     727              :         {
     728              :           /* We are done consuming the inserted tokens, so move
     729              :             onto the next original source token.  */
     730           48 :           InsertionIndex = 0;
     731           48 :           CurrentTokNo += 1;
     732              :         }
     733              :     }
     734    958197148 :   else if ((tokdesc->insert != NULL) && (InsertionIndex == 0))
     735              :     {
     736              :       /* avoid dangling else.  */
     737              :       /* This source token has extra tokens appended after it by the error recovery.
     738              :          Set the index ready for the next UpdateToken which will read the extra
     739              :          tokens.  */
     740           24 :       InsertionIndex = 1;
     741              :       /* However this call must read the original token.  */
     742           24 :       CopyOutCurrent (buffer, index, 0);
     743              :     }
     744              :   else
     745              :     {
     746              :       /* avoid dangling else.  */
     747    958197124 :       CopyOutCurrent (buffer, index, 0);
     748              :       /* Move onto the next original source token.  */
     749    958197124 :       CurrentTokNo += 1;
     750              :     }
     751    958197196 : }
     752              : 
     753              : 
     754              : /*
     755              :    GetTokenFiltered - providing that we have not already seen an eof for this source
     756              :                       file call m2flex.GetToken and GetToken if requested.
     757              : */
     758              : 
     759    192217149 : static void GetTokenFiltered (bool callGetToken)
     760              : {
     761    192217149 :   if (SeenEof)
     762              :     {
     763            0 :       M2LexBuf_currenttoken = M2Reserved_eoftok;
     764              :     }
     765              :   else
     766              :     {
     767              :       /* Call the lexical phase to place a new token into the last bucket.  */
     768    192217149 :       m2flex_GetToken ();
     769    192217149 :       if (callGetToken)
     770              :         {
     771            0 :           M2LexBuf_GetToken ();
     772              :         }
     773              :     }
     774    192217149 : }
     775              : 
     776              : 
     777              : /*
     778              :    AppendInsertToken -
     779              : */
     780              : 
     781          174 : static void AppendInsertToken (Indexing_Index index, M2LexBuf_TokenDesc tokdesc)
     782              : {
     783          174 :   if (Indexing_IsEmpty (index))
     784              :     {
     785          108 :       Indexing_PutIndice (index, Indexing_LowIndice (index), reinterpret_cast <void *> (tokdesc));
     786              :     }
     787              :   else
     788              :     {
     789           66 :       Indexing_PutIndice (index, (Indexing_HighIndice (index))+1, reinterpret_cast <void *> (tokdesc));
     790              :     }
     791          174 : }
     792              : 
     793              : 
     794              : /*
     795              :    DupTok - duplicate tokdesc and replaces the token field with token.
     796              : */
     797              : 
     798          174 : static M2LexBuf_TokenDesc DupTok (M2LexBuf_TokenDesc tokdesc, M2Reserved_toktype token)
     799              : {
     800          174 :   M2LexBuf_TokenDesc dup;
     801              : 
     802          174 :   Storage_ALLOCATE ((void **) &dup, sizeof (M2LexBuf__T2));
     803          174 :   M2Debug_Assert (dup != NULL);
     804          174 :   (*dup) = (*tokdesc);
     805          174 :   dup->token = token;
     806          174 :   return dup;
     807              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     808              :   __builtin_unreachable ();
     809              : }
     810              : 
     811              : 
     812              : /*
     813              :    AddTokToList - adds a token to a dynamic list.
     814              : */
     815              : 
     816    204509034 : static void AddTokToList (M2Reserved_toktype token, NameKey_Name str, int int_, unsigned int line, unsigned int col, M2LexBuf_SourceList file, location_t location)
     817              : {
     818    204509034 :   Append (ListOfTokens, InitTokenDesc (token, str, int_, line, col, file, location));
     819    204509034 : }
     820              : 
     821              : 
     822              : /*
     823              :    IsLastTokenEof - returns TRUE if the last token was an eoftok
     824              : */
     825              : 
     826       259860 : static bool IsLastTokenEof (void)
     827              : {
     828       259860 :   M2LexBuf_TokenDesc tokdesc;
     829              : 
     830       259860 :   if (Indexing_IsEmpty (ListOfTokens))
     831              :     {
     832              :       return false;
     833              :     }
     834              :   else
     835              :     {
     836       259860 :       tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, Indexing_HighIndice (ListOfTokens)));
     837       259860 :       return tokdesc->token == M2Reserved_eoftok;
     838              :     }
     839              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     840              :   __builtin_unreachable ();
     841              : }
     842              : 
     843              : 
     844              : /*
     845              :    isSrcToken - returns TRUE if tokenno is associated with
     846              :                 program source code.
     847              : */
     848              : 
     849            0 : static bool isSrcToken (unsigned int tokenno)
     850              : {
     851            0 :   return (tokenno != M2LexBuf_UnknownTokenNo) && (tokenno != M2LexBuf_BuiltinTokenNo);
     852              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     853              :   __builtin_unreachable ();
     854              : }
     855              : 
     856              : 
     857              : /*
     858              :    tprintf0 -
     859              : */
     860              : 
     861      1233137 : static void tprintf0 (const char *format_, unsigned int _format_high)
     862              : {
     863      1233137 :   char format[_format_high+1];
     864              : 
     865              :   /* make a local copy of each unbounded array.  */
     866      1233137 :   memcpy (format, format_, _format_high+1);
     867              : 
     868      1233137 :   if (Tracing)
     869              :     {
     870              :       M2Printf_printf0 ((const char *) format, _format_high);
     871              :     }
     872      1233137 : }
     873              : 
     874              : 
     875              : /*
     876              :    tprintf1 -
     877              : */
     878              : 
     879      1233418 : static void tprintf1 (const char *format_, unsigned int _format_high, DynamicStrings_String str)
     880              : {
     881      1233418 :   char format[_format_high+1];
     882              : 
     883              :   /* make a local copy of each unbounded array.  */
     884      1233418 :   memcpy (format, format_, _format_high+1);
     885              : 
     886      1233418 :   if (Tracing)
     887              :     {
     888              :       M2Printf_printf1 ((const char *) format, _format_high, (const unsigned char *) &str, (sizeof (str)-1));
     889              :     }
     890      1233418 : }
     891              : 
     892              : 
     893              : /*
     894              :    OpenSource - Attempts to open the source file, s.
     895              :                 The success of the operation is returned.
     896              : */
     897              : 
     898      1233418 : extern "C" bool M2LexBuf_OpenSource (DynamicStrings_String s)
     899              : {
     900      1233418 :   tprintf1 ((const char *) "OpenSource (%s)\\n", 17, s);
     901      1233418 :   SeenEof = false;
     902      1233418 :   if (UseBufferedTokens)
     903              :     {
     904       973557 :       M2LexBuf_GetToken ();
     905       973557 :       return true;
     906              :     }
     907              :   else
     908              :     {
     909       259861 :       if (m2flex_OpenSource (DynamicStrings_string (s)))
     910              :         {
     911       259860 :           M2LexBuf_SetFile (DynamicStrings_string (s));
     912       259860 :           M2LexBuf_GetToken ();
     913       259860 :           if (IsLastTokenEof ())
     914              :             {
     915            6 :               M2MetaError_MetaErrorT0 (M2LexBuf_GetTokenNo (), (const char *) "source file is empty", 20);
     916              :             }
     917       259860 :           return true;
     918              :         }
     919              :       else
     920              :         {
     921              :           return false;
     922              :         }
     923              :     }
     924              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     925              :   __builtin_unreachable ();
     926              : }
     927              : 
     928              : 
     929              : /*
     930              :    CloseSource - closes the current open file.
     931              : */
     932              : 
     933      1233137 : extern "C" void M2LexBuf_CloseSource (void)
     934              : {
     935      1233137 :   tprintf0 ((const char *) "CloseSource\\n", 13);
     936      1233137 :   if (UseBufferedTokens)
     937              :     {
     938       973295 :       while (M2LexBuf_currenttoken != M2Reserved_eoftok)
     939              :         {
     940            0 :           M2LexBuf_GetToken ();
     941              :         }
     942              :     }
     943              :   /* a subsequent call to m2flex.OpenSource will really close the file  */
     944      1233137 : }
     945              : 
     946              : 
     947              : /*
     948              :    ReInitialize - re-initialize the all the data structures.
     949              : */
     950              : 
     951        14945 : extern "C" void M2LexBuf_ReInitialize (void)
     952              : {
     953        14945 :   Indexing_ForeachIndiceInIndexDo (ListOfTokens, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) DeleteTokenDesc});
     954        14945 :   CurrentUsed = false;
     955        14945 :   KillList ();
     956        14945 :   Init ();
     957        14945 : }
     958              : 
     959              : 
     960              : /*
     961              :    ResetForNewPass - reset the buffer pointers to the beginning ready for
     962              :                      a new pass
     963              : */
     964              : 
     965        58875 : extern "C" void M2LexBuf_ResetForNewPass (void)
     966              : {
     967        58875 :   InsertionIndex = 0;
     968        58875 :   CurrentTokNo = InitialSourceToken;
     969        58875 :   UseBufferedTokens = true;
     970        58875 : }
     971              : 
     972              : 
     973              : /*
     974              :    GetToken - gets the next token into currenttoken.
     975              : */
     976              : 
     977    958197196 : extern "C" void M2LexBuf_GetToken (void)
     978              : {
     979    958197196 :   typedef struct GetToken__T3_a GetToken__T3;
     980              : 
     981    958197196 :   struct GetToken__T3_a { char array[20+1]; };
     982    958197196 :   GetToken__T3 buf;
     983              : 
     984    958197196 :   if (UseBufferedTokens)
     985              :     {
     986              :       /* avoid dangling else.  */
     987    765979999 :       UpdateToken (ListOfTokens, CurrentTokNo);
     988    765979999 :       if (M2Options_GetDebugTraceToken ())
     989              :         {
     990            0 :           NumberIO_CardToStr (CurrentTokNo, 0, (char *) &buf.array[0], 20);
     991            0 :           FIO_WriteString (M2LangDump_GetDumpFile (), (const char *) "token: ", 7);
     992            0 :           FIO_WriteString (M2LangDump_GetDumpFile (), (const char *) &buf.array[0], 20);
     993            0 :           FIO_WriteLine (M2LangDump_GetDumpFile ());
     994              :         }
     995              :     }
     996              :   else
     997              :     {
     998    192217197 :       if (! (Indexing_InBounds (ListOfTokens, CurrentTokNo)))
     999              :         {
    1000    192217149 :           GetTokenFiltered (false);
    1001              :         }
    1002    192217197 :       UpdateToken (ListOfTokens, CurrentTokNo);
    1003    192217197 :       if (M2Options_GetDebugTraceToken ())
    1004              :         {
    1005            0 :           NumberIO_CardToStr (CurrentTokNo, 0, (char *) &buf.array[0], 20);
    1006            0 :           m2flex_M2Error (&buf);
    1007              :         }
    1008              :     }
    1009    958197196 : }
    1010              : 
    1011              : 
    1012              : /*
    1013              :    InsertToken - inserts a symbol token infront of the current token
    1014              :                  ready for the next pass.
    1015              : */
    1016              : 
    1017          150 : extern "C" void M2LexBuf_InsertToken (M2Reserved_toktype token)
    1018              : {
    1019          150 :   unsigned int prev;
    1020          150 :   M2LexBuf_TokenDesc tokdesc;
    1021              : 
    1022          150 :   M2Debug_Assert (ListOfTokens != NULL);
    1023          150 :   M2Debug_Assert (! (Indexing_IsEmpty (ListOfTokens)));
    1024          150 :   prev = (M2LexBuf_GetTokenNo ())-1;
    1025          150 :   tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, prev));
    1026          150 :   if (tokdesc->insert == NULL)
    1027              :     {
    1028          108 :       tokdesc->insert = Indexing_InitIndex (1);
    1029              :     }
    1030          150 :   AppendInsertToken (tokdesc->insert, DupTok (tokdesc, token));
    1031          150 : }
    1032              : 
    1033              : 
    1034              : /*
    1035              :    InsertTokenAndRewind - inserts a symbol token infront of the current token
    1036              :                           and then moves the token stream back onto the inserted
    1037              :                           token.
    1038              : */
    1039              : 
    1040           24 : extern "C" void M2LexBuf_InsertTokenAndRewind (M2Reserved_toktype token)
    1041              : {
    1042           24 :   unsigned int position;
    1043           24 :   M2LexBuf_TokenDesc tokdesc;
    1044              : 
    1045           24 :   if ((M2LexBuf_GetTokenNo ()) > 0)
    1046              :     {
    1047           24 :       M2LexBuf_InsertToken (token);
    1048           24 :       position = CurrentTokNo-2;
    1049           24 :       tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, position));
    1050           24 :       if (tokdesc->insert == NULL)
    1051              :         {
    1052            0 :           tokdesc->insert = Indexing_InitIndex (1);
    1053              :         }
    1054           24 :       AppendInsertToken (tokdesc->insert, DupTok (tokdesc, token));
    1055           24 :       InsertionIndex = Indexing_HighIndice (tokdesc->insert);
    1056           24 :       CurrentTokNo -= 2;
    1057           24 :       M2LexBuf_GetToken ();
    1058              :     }
    1059           24 : }
    1060              : 
    1061              : 
    1062              : /*
    1063              :    GetPreviousTokenLineNo - returns the line number of the previous token.
    1064              : */
    1065              : 
    1066        78968 : extern "C" unsigned int M2LexBuf_GetPreviousTokenLineNo (void)
    1067              : {
    1068        78968 :   return M2LexBuf_GetLineNo ();
    1069              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1070              :   __builtin_unreachable ();
    1071              : }
    1072              : 
    1073              : 
    1074              : /*
    1075              :    GetLineNo - returns the current line number where the symbol occurs in
    1076              :                the source file.
    1077              : */
    1078              : 
    1079      8243759 : extern "C" unsigned int M2LexBuf_GetLineNo (void)
    1080              : {
    1081      8243759 :   if (CurrentTokNo == 0)
    1082              :     {
    1083              :       return 0;
    1084              :     }
    1085              :   else
    1086              :     {
    1087      8243759 :       return M2LexBuf_TokenToLineNo (M2LexBuf_GetTokenNo (), 0);
    1088              :     }
    1089              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1090              :   __builtin_unreachable ();
    1091              : }
    1092              : 
    1093              : 
    1094              : /*
    1095              :    GetTokenNo - returns the current token number.
    1096              : */
    1097              : 
    1098    154362969 : extern "C" unsigned int M2LexBuf_GetTokenNo (void)
    1099              : {
    1100    154362969 :   if (CurrentTokNo == 0)
    1101              :     {
    1102              :       return 0;
    1103              :     }
    1104              :   else
    1105              :     {
    1106    154362969 :       return CurrentTokNo-1;
    1107              :     }
    1108              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1109              :   __builtin_unreachable ();
    1110              : }
    1111              : 
    1112              : 
    1113              : /*
    1114              :    GetTokenName - returns the token name given the tokenno.
    1115              : */
    1116              : 
    1117            0 : extern "C" NameKey_Name M2LexBuf_GetTokenName (unsigned int tokenno)
    1118              : {
    1119            0 :   M2LexBuf_TokenDesc tokdesc;
    1120            0 :   NameKey_Name name;
    1121              : 
    1122            0 :   if (Indexing_InBounds (ListOfTokens, tokenno))
    1123              :     {
    1124            0 :       tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, tokenno));
    1125            0 :       name = M2Reserved_tokToTok (tokdesc->token);
    1126            0 :       if (name == NameKey_NulName)
    1127              :         {
    1128            0 :           return tokdesc->str;
    1129              :         }
    1130              :       else
    1131              :         {
    1132              :           return name;
    1133              :         }
    1134              :     }
    1135              :   return NameKey_NulName;
    1136              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1137              :   __builtin_unreachable ();
    1138              : }
    1139              : 
    1140              : 
    1141              : /*
    1142              :    TokenToLineNo - returns the line number of the current file for the
    1143              :                    tokenno. The depth refers to the include depth.
    1144              :                    A depth of 0 is the current file, depth of 1 is the file
    1145              :                    which included the current file. Zero is returned if the
    1146              :                    depth exceeds the file nesting level.
    1147              : */
    1148              : 
    1149      8256466 : extern "C" unsigned int M2LexBuf_TokenToLineNo (unsigned int tokenno, unsigned int depth)
    1150              : {
    1151      8256466 :   M2LexBuf_TokenDesc tokdesc;
    1152      8256466 :   M2LexBuf_SourceList level;
    1153              : 
    1154      8256466 :   if ((tokenno != M2LexBuf_UnknownTokenNo) && (tokenno != M2LexBuf_BuiltinTokenNo))
    1155              :     {
    1156      8256466 :       if (Indexing_InBounds (ListOfTokens, tokenno))
    1157              :         {
    1158      8256466 :           tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, tokenno));
    1159      8256466 :           if (depth == 0)
    1160              :             {
    1161      8256466 :               return tokdesc->line;
    1162              :             }
    1163              :           else
    1164              :             {
    1165            0 :               level = tokdesc->file->left;
    1166            0 :               while (depth > 0)
    1167              :                 {
    1168            0 :                   level = level->left;
    1169            0 :                   if (level == tokdesc->file->left)
    1170              :                     {
    1171              :                       return 0;
    1172              :                     }
    1173            0 :                   depth -= 1;
    1174              :                 }
    1175            0 :               return level->line;
    1176              :             }
    1177              :         }
    1178              :     }
    1179              :   return 0;
    1180              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1181              :   __builtin_unreachable ();
    1182              : }
    1183              : 
    1184              : 
    1185              : /*
    1186              :    GetColumnNo - returns the current column where the symbol occurs in
    1187              :                  the source file.
    1188              : */
    1189              : 
    1190            0 : extern "C" unsigned int M2LexBuf_GetColumnNo (void)
    1191              : {
    1192            0 :   if (CurrentTokNo == 0)
    1193              :     {
    1194              :       return 0;
    1195              :     }
    1196              :   else
    1197              :     {
    1198            0 :       return M2LexBuf_TokenToColumnNo (M2LexBuf_GetTokenNo (), 0);
    1199              :     }
    1200              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1201              :   __builtin_unreachable ();
    1202              : }
    1203              : 
    1204              : 
    1205              : /*
    1206              :    TokenToColumnNo - returns the column number of the current file for the
    1207              :                      tokenno. The depth refers to the include depth.
    1208              :                      A depth of 0 is the current file, depth of 1 is the file
    1209              :                      which included the current file. Zero is returned if the
    1210              :                      depth exceeds the file nesting level.
    1211              : */
    1212              : 
    1213        12707 : extern "C" unsigned int M2LexBuf_TokenToColumnNo (unsigned int tokenno, unsigned int depth)
    1214              : {
    1215        12707 :   M2LexBuf_TokenDesc tokdesc;
    1216        12707 :   M2LexBuf_SourceList level;
    1217              : 
    1218        12707 :   if ((tokenno != M2LexBuf_UnknownTokenNo) && (tokenno != M2LexBuf_BuiltinTokenNo))
    1219              :     {
    1220        12707 :       if (Indexing_InBounds (ListOfTokens, tokenno))
    1221              :         {
    1222        12707 :           tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, tokenno));
    1223        12707 :           if (depth == 0)
    1224              :             {
    1225        12707 :               return tokdesc->col;
    1226              :             }
    1227              :           else
    1228              :             {
    1229            0 :               level = tokdesc->file->left;
    1230            0 :               while (depth > 0)
    1231              :                 {
    1232            0 :                   level = level->left;
    1233            0 :                   if (level == tokdesc->file->left)
    1234              :                     {
    1235              :                       return 0;
    1236              :                     }
    1237            0 :                   depth -= 1;
    1238              :                 }
    1239            0 :               return level->col;
    1240              :             }
    1241              :         }
    1242              :     }
    1243              :   return 0;
    1244              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1245              :   __builtin_unreachable ();
    1246              : }
    1247              : 
    1248              : 
    1249              : /*
    1250              :    TokenToLocation - returns the location_t corresponding to tokenno.
    1251              : */
    1252              : 
    1253     77007649 : extern "C" location_t M2LexBuf_TokenToLocation (unsigned int tokenno)
    1254              : {
    1255     77007649 :   M2LexBuf_TokenDesc tokdesc;
    1256              : 
    1257     77007649 :   if (tokenno == M2LexBuf_UnknownTokenNo)
    1258              :     {
    1259     15255104 :       return M2Emit_UnknownLocation ();
    1260              :     }
    1261     61752545 :   else if (tokenno == M2LexBuf_BuiltinTokenNo)
    1262              :     {
    1263              :       /* avoid dangling else.  */
    1264       493130 :       return M2Emit_BuiltinsLocation ();
    1265              :     }
    1266     61259415 :   else if (Indexing_InBounds (ListOfTokens, tokenno))
    1267              :     {
    1268              :       /* avoid dangling else.  */
    1269     61259415 :       tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, tokenno));
    1270     61259415 :       return tokdesc->loc;
    1271              :     }
    1272            0 :   return M2Emit_UnknownLocation ();
    1273              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1274              :   __builtin_unreachable ();
    1275              : }
    1276              : 
    1277              : 
    1278              : /*
    1279              :    FindFileNameFromToken - returns the complete FileName for the appropriate
    1280              :                            source file yields the token number, TokenNo.
    1281              :                            The, Depth, indicates the include level: 0..n
    1282              :                            Level 0 is the current. NIL is returned if n+1
    1283              :                            is requested.
    1284              : */
    1285              : 
    1286       710622 : extern "C" DynamicStrings_String M2LexBuf_FindFileNameFromToken (unsigned int tokenno, unsigned int depth)
    1287              : {
    1288       710622 :   M2LexBuf_TokenDesc tokdesc;
    1289       710622 :   M2LexBuf_SourceList level;
    1290              : 
    1291       710622 :   if ((tokenno != M2LexBuf_UnknownTokenNo) && (tokenno != M2LexBuf_BuiltinTokenNo))
    1292              :     {
    1293       710522 :       if (Indexing_InBounds (ListOfTokens, tokenno))
    1294              :         {
    1295       710522 :           tokdesc = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, tokenno));
    1296       710522 :           level = tokdesc->file->left;
    1297       714249 :           while (depth > 0)
    1298              :             {
    1299         3727 :               level = level->left;
    1300         3727 :               if (level == tokdesc->file->left)
    1301              :                 {
    1302              :                   return static_cast<DynamicStrings_String> (NULL);
    1303              :                 }
    1304         3727 :               depth -= 1;
    1305              :             }
    1306       710522 :           return level->name;
    1307              :         }
    1308              :     }
    1309              :   return static_cast<DynamicStrings_String> (NULL);
    1310              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1311              :   __builtin_unreachable ();
    1312              : }
    1313              : 
    1314              : 
    1315              : /*
    1316              :    GetFileName - returns a String defining the current file.
    1317              : */
    1318              : 
    1319       694088 : extern "C" DynamicStrings_String M2LexBuf_GetFileName (void)
    1320              : {
    1321       694088 :   return M2LexBuf_FindFileNameFromToken (M2LexBuf_GetTokenNo (), 0);
    1322              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1323              :   __builtin_unreachable ();
    1324              : }
    1325              : 
    1326              : 
    1327              : /*
    1328              :    MakeVirtualTok - providing caret, left, right are associated with a source file
    1329              :                     and exist on the same src line then
    1330              :                     create and return a new tokenno which is created from
    1331              :                     tokenno left and right.  Otherwise return caret.
    1332              :                     If caret is UnknownTokenNo then it is replaced with left or right
    1333              :                     in sequence to avoid an UnknownTokenNo.
    1334              : */
    1335              : 
    1336     14088091 : extern "C" unsigned int M2LexBuf_MakeVirtualTok (unsigned int caret, unsigned int left, unsigned int right)
    1337              : {
    1338     14088091 :   M2LexBuf_TokenDesc descLeft;
    1339     14088091 :   M2LexBuf_TokenDesc descRight;
    1340     14088091 :   location_t lc;
    1341     14088091 :   location_t ll;
    1342     14088091 :   location_t lr;
    1343              : 
    1344     14088091 :   if (caret == M2LexBuf_UnknownTokenNo)
    1345              :     {
    1346        71732 :       caret = left;
    1347              :     }
    1348        71732 :   if (caret == M2LexBuf_UnknownTokenNo)
    1349              :     {
    1350        50308 :       caret = right;
    1351              :     }
    1352     14088091 :   if ((caret == left) && (left == right))
    1353              :     {
    1354              :       return caret;
    1355              :     }
    1356     12958572 :   if (((isSrcToken (caret)) && (isSrcToken (left))) && (isSrcToken (right)))
    1357              :     {
    1358     12604881 :       lc = M2LexBuf_TokenToLocation (caret);
    1359     12604881 :       ll = M2LexBuf_TokenToLocation (left);
    1360     12604881 :       lr = M2LexBuf_TokenToLocation (right);
    1361     12604881 :       if ((Indexing_InBounds (ListOfTokens, left)) && (Indexing_InBounds (ListOfTokens, right)))
    1362              :         {
    1363     12604881 :           descLeft = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, left));
    1364     12604881 :           descRight = static_cast<M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, right));
    1365     12604881 :           if ((descLeft->line == descRight->line) && (descLeft->file == descRight->file))
    1366              :             {
    1367              :               /* On the same line, create a new token and location.  */
    1368     12291885 :               AddTokToList (M2Reserved_virtualrangetok, NameKey_NulName, 0, descLeft->line, descLeft->col, descLeft->file, m2linemap_GetLocationBinary (lc, ll, lr));
    1369     12291885 :               caret = Indexing_HighIndice (ListOfTokens);
    1370              :             }
    1371              :         }
    1372              :     }
    1373              :   if (caret == BadTokenNo)
    1374              :     {
    1375              :       stop ();
    1376              :     }
    1377              :   return caret;
    1378              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1379              :   __builtin_unreachable ();
    1380              : }
    1381              : 
    1382              : 
    1383              : /*
    1384              :    MakeVirtual2Tok - creates and return a new tokenno which is created from
    1385              :                      two tokens left and right.  It tries to avoid UnknownTokenNo
    1386              :                      and will fall back to left or right if necessary.
    1387              : */
    1388              : 
    1389     11538515 : extern "C" unsigned int M2LexBuf_MakeVirtual2Tok (unsigned int left, unsigned int right)
    1390              : {
    1391     11538515 :   if (left == M2LexBuf_UnknownTokenNo)
    1392              :     {
    1393              :       left = right;
    1394              :     }
    1395     11538377 :   else if (right == M2LexBuf_UnknownTokenNo)
    1396              :     {
    1397              :       /* avoid dangling else.  */
    1398        21703 :       right = left;
    1399              :     }
    1400     11538515 :   return M2LexBuf_MakeVirtualTok (left, left, right);
    1401              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1402              :   __builtin_unreachable ();
    1403              : }
    1404              : 
    1405              : 
    1406              : /*
    1407              :    AddTok - adds a token to the buffer.
    1408              : */
    1409              : 
    1410    117569330 : extern "C" void M2LexBuf_AddTok (M2Reserved_toktype t)
    1411              : {
    1412    117569330 :   DynamicStrings_String s;
    1413              : 
    1414    117569330 :   if (Tracing)
    1415              :     {
    1416              :       M2Printf_printf0 ((const char *) " m2.flex -> AddTok ", 19);
    1417              :       M2LexBuf_DisplayToken (t);
    1418              :       M2Printf_printf0 ((const char *) "\\n", 2);
    1419              :     }
    1420    117569330 :   if ((t == M2Reserved_eoftok) && SeenEof)
    1421              :     {
    1422              :       /* avoid dangling else.  */
    1423              :       if (Debugging)
    1424              :         {
    1425              :           M2Printf_printf0 ((const char *) "extra eoftok ignored as buffer already contains eoftok\\n", 56);
    1426              :         }
    1427              :     }
    1428              :   else
    1429              :     {
    1430    117324415 :       if (Debugging)
    1431              :         {
    1432              :           M2Printf_printf0 ((const char *) "adding token: ", 14);
    1433              :           M2LexBuf_DisplayToken (t);
    1434              :           M2Printf_printf0 ((const char *) "\\n", 2);
    1435              :         }
    1436    117324415 :       AddTokToList (t, NameKey_NulName, 0, m2flex_GetLineNo (), m2flex_GetColumnNo (), CurrentSource, m2flex_GetLocation ());
    1437    117324415 :       CurrentUsed = true;
    1438    117324415 :       if (Debugging)
    1439              :         {
    1440              :           /* display each token as a warning.  */
    1441              :           s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (M2LexBuf_GetTokenName (M2LexBuf_GetTokenNo ())));
    1442              :           M2Error_WarnStringAt (s, M2LexBuf_GetTokenNo ());
    1443              :         }
    1444    117324415 :       if (t == M2Reserved_eoftok)
    1445              :         {
    1446       244903 :           SeenEof = true;
    1447              :         }
    1448              :     }
    1449    117569330 : }
    1450              : 
    1451              : 
    1452              : /*
    1453              :    AddTokCharStar - adds a token to the buffer and an additional string, s.
    1454              :                     A copy of string, s, is made.
    1455              : */
    1456              : 
    1457     74709884 : extern "C" void M2LexBuf_AddTokCharStar (M2Reserved_toktype t, void * s)
    1458              : {
    1459     74709884 :   DynamicStrings_String str;
    1460              : 
    1461     74709884 :   M2Debug_Assert (t != M2Reserved_eoftok);
    1462     74709884 :   if (Tracing)
    1463              :     {
    1464              :       M2Printf_printf0 ((const char *) " m2.flex -> AddTokCharStar ", 27);
    1465              :       M2LexBuf_DisplayToken (t);
    1466              :       str = DynamicStrings_InitStringCharStar (s);
    1467              :       M2Printf_printf1 ((const char *) " %s\\n", 5, (const unsigned char *) &str, (sizeof (str)-1));
    1468              :       str = DynamicStrings_KillString (str);
    1469              :     }
    1470     74709884 :   if (Debugging)
    1471              :     {
    1472              :       M2Printf_printf0 ((const char *) "AddTokCharStar: ", 16);
    1473              :       M2LexBuf_DisplayToken (t);
    1474              :       M2Printf_printf0 ((const char *) "\\n", 2);
    1475              :     }
    1476     74709884 :   AddTokToList (t, NameKey_makekey (s), 0, m2flex_GetLineNo (), m2flex_GetColumnNo (), CurrentSource, m2flex_GetLocation ());
    1477     74709884 :   CurrentUsed = true;
    1478     74709884 : }
    1479              : 
    1480              : 
    1481              : /*
    1482              :    AddTokInteger - adds a token and an integer to the buffer.
    1483              : */
    1484              : 
    1485       182850 : extern "C" void M2LexBuf_AddTokInteger (M2Reserved_toktype t, int i)
    1486              : {
    1487       182850 :   DynamicStrings_String s;
    1488       182850 :   unsigned int c;
    1489       182850 :   unsigned int l;
    1490              : 
    1491       182850 :   M2Debug_Assert (t != M2Reserved_eoftok);
    1492       182850 :   if (Tracing)
    1493              :     {
    1494              :       M2Printf_printf0 ((const char *) " m2.flex -> AddTokInteger ", 26);
    1495              :       M2LexBuf_DisplayToken (t);
    1496              :       M2Printf_printf1 ((const char *) " %d\\n", 5, (const unsigned char *) &i, (sizeof (i)-1));
    1497              :     }
    1498       182850 :   l = m2flex_GetLineNo ();
    1499       182850 :   c = m2flex_GetColumnNo ();
    1500       182850 :   s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%d", 2)), (const unsigned char *) &i, (sizeof (i)-1));
    1501       182850 :   AddTokToList (t, NameKey_makekey (DynamicStrings_string (s)), i, l, c, CurrentSource, m2flex_GetLocation ());
    1502       182850 :   s = DynamicStrings_KillString (s);
    1503       182850 :   CurrentUsed = true;
    1504       182850 : }
    1505              : 
    1506              : 
    1507              : /*
    1508              :    SetFile - sets the current filename to, filename.
    1509              : */
    1510              : 
    1511       292144 : extern "C" void M2LexBuf_SetFile (void * filename)
    1512              : {
    1513       292144 :   KillList ();
    1514       292144 :   CurrentUsed = false;
    1515       292144 :   CurrentSource = NewList ();
    1516       292144 :   AddTo (NewElement (filename));
    1517       292144 : }
    1518              : 
    1519              : 
    1520              : /*
    1521              :    PushFile - indicates that, filename, has just been included.
    1522              : */
    1523              : 
    1524            0 : extern "C" void M2LexBuf_PushFile (void * filename)
    1525              : {
    1526            0 :   M2LexBuf_SourceList l;
    1527              : 
    1528            0 :   CheckIfNeedToDuplicate ();
    1529            0 :   AddTo (NewElement (filename));
    1530            0 :   if (Debugging)
    1531              :     {
    1532              :       if (CurrentSource->right != CurrentSource)
    1533              :         {
    1534              :           l = CurrentSource;
    1535              :           do {
    1536              :             M2Printf_printf3 ((const char *) "name = %s, line = %d, col = %d\\n", 32, (const unsigned char *) &l->name, (sizeof (l->name)-1), (const unsigned char *) &l->line, (sizeof (l->line)-1), (const unsigned char *) &l->col, (sizeof (l->col)-1));
    1537              :             l = l->right;
    1538              :           } while (! (l == CurrentSource));
    1539              :         }
    1540              :     }
    1541            0 : }
    1542              : 
    1543              : 
    1544              : /*
    1545              :    PopFile - indicates that we are returning to, filename, having finished
    1546              :              an include.
    1547              : */
    1548              : 
    1549            0 : extern "C" void M2LexBuf_PopFile (void * filename)
    1550              : {
    1551            0 :   M2LexBuf_SourceList l;
    1552              : 
    1553            0 :   CheckIfNeedToDuplicate ();
    1554            0 :   if ((CurrentSource != NULL) && (CurrentSource->left != CurrentSource))
    1555              :     {
    1556              :       /* avoid dangling else.  */
    1557            0 :       l = CurrentSource->left;  /* last element  */
    1558            0 :       SubFrom (l);  /* last element  */
    1559            0 :       Storage_DEALLOCATE ((void **) &l, sizeof (M2LexBuf__T1));
    1560            0 :       if ((CurrentSource->left != CurrentSource) && (! (DynamicStrings_Equal (CurrentSource->name, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (filename))))))
    1561              :         {}  /* empty.  */
    1562              :       /* mismatch in source file names after preprocessing files  */
    1563              :     }
    1564              :   /* source file list is empty, cannot pop an include..  */
    1565            0 : }
    1566              : 
    1567              : 
    1568              : /*
    1569              :    PrintTokenNo - displays token and the location of the token.
    1570              : */
    1571              : 
    1572            0 : extern "C" void M2LexBuf_PrintTokenNo (unsigned int tokenno)
    1573              : {
    1574            0 :   DynamicStrings_String s;
    1575              : 
    1576            0 :   M2Printf_printf1 ((const char *) "tokenno = %d, ", 14, (const unsigned char *) &tokenno, (sizeof (tokenno)-1));
    1577            0 :   s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (M2LexBuf_GetTokenName (tokenno)));
    1578            0 :   M2Printf_printf1 ((const char *) "%s\\n", 4, (const unsigned char *) &s, (sizeof (s)-1));
    1579            0 :   s = DynamicStrings_KillString (s);
    1580            0 : }
    1581              : 
    1582              : 
    1583              : /*
    1584              :    DisplayToken - display the token name using printf0 no newline is emitted.
    1585              : */
    1586              : 
    1587            0 : extern "C" void M2LexBuf_DisplayToken (M2Reserved_toktype tok)
    1588              : {
    1589            0 :   switch (tok)
    1590              :     {
    1591            0 :       case M2Reserved_eoftok:
    1592            0 :         M2Printf_printf0 ((const char *) "eoftok", 6);
    1593            0 :         break;
    1594              : 
    1595            0 :       case M2Reserved_plustok:
    1596            0 :         M2Printf_printf0 ((const char *) "plustok", 7);
    1597            0 :         break;
    1598              : 
    1599            0 :       case M2Reserved_minustok:
    1600            0 :         M2Printf_printf0 ((const char *) "minustok", 8);
    1601            0 :         break;
    1602              : 
    1603            0 :       case M2Reserved_timestok:
    1604            0 :         M2Printf_printf0 ((const char *) "timestok", 8);
    1605            0 :         break;
    1606              : 
    1607            0 :       case M2Reserved_dividetok:
    1608            0 :         M2Printf_printf0 ((const char *) "dividetok", 9);
    1609            0 :         break;
    1610              : 
    1611            0 :       case M2Reserved_becomestok:
    1612            0 :         M2Printf_printf0 ((const char *) "becomestok", 10);
    1613            0 :         break;
    1614              : 
    1615            0 :       case M2Reserved_ambersandtok:
    1616            0 :         M2Printf_printf0 ((const char *) "ambersandtok", 12);
    1617            0 :         break;
    1618              : 
    1619            0 :       case M2Reserved_periodtok:
    1620            0 :         M2Printf_printf0 ((const char *) "periodtok", 9);
    1621            0 :         break;
    1622              : 
    1623            0 :       case M2Reserved_commatok:
    1624            0 :         M2Printf_printf0 ((const char *) "commatok", 8);
    1625            0 :         break;
    1626              : 
    1627            0 :       case M2Reserved_semicolontok:
    1628            0 :         M2Printf_printf0 ((const char *) "semicolontok", 12);
    1629            0 :         break;
    1630              : 
    1631            0 :       case M2Reserved_lparatok:
    1632            0 :         M2Printf_printf0 ((const char *) "lparatok", 8);
    1633            0 :         break;
    1634              : 
    1635            0 :       case M2Reserved_rparatok:
    1636            0 :         M2Printf_printf0 ((const char *) "rparatok", 8);
    1637            0 :         break;
    1638              : 
    1639            0 :       case M2Reserved_lsbratok:
    1640            0 :         M2Printf_printf0 ((const char *) "lsbratok", 8);
    1641            0 :         break;
    1642              : 
    1643            0 :       case M2Reserved_rsbratok:
    1644            0 :         M2Printf_printf0 ((const char *) "rsbratok", 8);
    1645            0 :         break;
    1646              : 
    1647            0 :       case M2Reserved_lcbratok:
    1648            0 :         M2Printf_printf0 ((const char *) "lcbratok", 8);
    1649            0 :         break;
    1650              : 
    1651            0 :       case M2Reserved_rcbratok:
    1652            0 :         M2Printf_printf0 ((const char *) "rcbratok", 8);
    1653            0 :         break;
    1654              : 
    1655            0 :       case M2Reserved_uparrowtok:
    1656            0 :         M2Printf_printf0 ((const char *) "uparrowtok", 10);
    1657            0 :         break;
    1658              : 
    1659            0 :       case M2Reserved_singlequotetok:
    1660            0 :         M2Printf_printf0 ((const char *) "singlequotetok", 14);
    1661            0 :         break;
    1662              : 
    1663            0 :       case M2Reserved_equaltok:
    1664            0 :         M2Printf_printf0 ((const char *) "equaltok", 8);
    1665            0 :         break;
    1666              : 
    1667            0 :       case M2Reserved_hashtok:
    1668            0 :         M2Printf_printf0 ((const char *) "hashtok", 7);
    1669            0 :         break;
    1670              : 
    1671            0 :       case M2Reserved_lesstok:
    1672            0 :         M2Printf_printf0 ((const char *) "lesstok", 7);
    1673            0 :         break;
    1674              : 
    1675            0 :       case M2Reserved_greatertok:
    1676            0 :         M2Printf_printf0 ((const char *) "greatertok", 10);
    1677            0 :         break;
    1678              : 
    1679            0 :       case M2Reserved_lessgreatertok:
    1680            0 :         M2Printf_printf0 ((const char *) "lessgreatertok", 14);
    1681            0 :         break;
    1682              : 
    1683            0 :       case M2Reserved_lessequaltok:
    1684            0 :         M2Printf_printf0 ((const char *) "lessequaltok", 12);
    1685            0 :         break;
    1686              : 
    1687            0 :       case M2Reserved_greaterequaltok:
    1688            0 :         M2Printf_printf0 ((const char *) "greaterequaltok", 15);
    1689            0 :         break;
    1690              : 
    1691            0 :       case M2Reserved_periodperiodtok:
    1692            0 :         M2Printf_printf0 ((const char *) "periodperiodtok", 15);
    1693            0 :         break;
    1694              : 
    1695            0 :       case M2Reserved_colontok:
    1696            0 :         M2Printf_printf0 ((const char *) "colontok", 8);
    1697            0 :         break;
    1698              : 
    1699            0 :       case M2Reserved_doublequotestok:
    1700            0 :         M2Printf_printf0 ((const char *) "doublequotestok", 15);
    1701            0 :         break;
    1702              : 
    1703            0 :       case M2Reserved_bartok:
    1704            0 :         M2Printf_printf0 ((const char *) "bartok", 6);
    1705            0 :         break;
    1706              : 
    1707            0 :       case M2Reserved_andtok:
    1708            0 :         M2Printf_printf0 ((const char *) "andtok", 6);
    1709            0 :         break;
    1710              : 
    1711            0 :       case M2Reserved_arraytok:
    1712            0 :         M2Printf_printf0 ((const char *) "arraytok", 8);
    1713            0 :         break;
    1714              : 
    1715            0 :       case M2Reserved_begintok:
    1716            0 :         M2Printf_printf0 ((const char *) "begintok", 8);
    1717            0 :         break;
    1718              : 
    1719            0 :       case M2Reserved_bytok:
    1720            0 :         M2Printf_printf0 ((const char *) "bytok", 5);
    1721            0 :         break;
    1722              : 
    1723            0 :       case M2Reserved_casetok:
    1724            0 :         M2Printf_printf0 ((const char *) "casetok", 7);
    1725            0 :         break;
    1726              : 
    1727            0 :       case M2Reserved_consttok:
    1728            0 :         M2Printf_printf0 ((const char *) "consttok", 8);
    1729            0 :         break;
    1730              : 
    1731            0 :       case M2Reserved_definitiontok:
    1732            0 :         M2Printf_printf0 ((const char *) "definitiontok", 13);
    1733            0 :         break;
    1734              : 
    1735            0 :       case M2Reserved_divtok:
    1736            0 :         M2Printf_printf0 ((const char *) "divtok", 6);
    1737            0 :         break;
    1738              : 
    1739            0 :       case M2Reserved_dotok:
    1740            0 :         M2Printf_printf0 ((const char *) "dotok", 5);
    1741            0 :         break;
    1742              : 
    1743            0 :       case M2Reserved_elsetok:
    1744            0 :         M2Printf_printf0 ((const char *) "elsetok", 7);
    1745            0 :         break;
    1746              : 
    1747            0 :       case M2Reserved_elsiftok:
    1748            0 :         M2Printf_printf0 ((const char *) "elsiftok", 8);
    1749            0 :         break;
    1750              : 
    1751            0 :       case M2Reserved_endtok:
    1752            0 :         M2Printf_printf0 ((const char *) "endtok", 6);
    1753            0 :         break;
    1754              : 
    1755            0 :       case M2Reserved_exittok:
    1756            0 :         M2Printf_printf0 ((const char *) "exittok", 7);
    1757            0 :         break;
    1758              : 
    1759            0 :       case M2Reserved_exporttok:
    1760            0 :         M2Printf_printf0 ((const char *) "exporttok", 9);
    1761            0 :         break;
    1762              : 
    1763            0 :       case M2Reserved_fortok:
    1764            0 :         M2Printf_printf0 ((const char *) "fortok", 6);
    1765            0 :         break;
    1766              : 
    1767            0 :       case M2Reserved_fromtok:
    1768            0 :         M2Printf_printf0 ((const char *) "fromtok", 7);
    1769            0 :         break;
    1770              : 
    1771            0 :       case M2Reserved_iftok:
    1772            0 :         M2Printf_printf0 ((const char *) "iftok", 5);
    1773            0 :         break;
    1774              : 
    1775            0 :       case M2Reserved_implementationtok:
    1776            0 :         M2Printf_printf0 ((const char *) "implementationtok", 17);
    1777            0 :         break;
    1778              : 
    1779            0 :       case M2Reserved_importtok:
    1780            0 :         M2Printf_printf0 ((const char *) "importtok", 9);
    1781            0 :         break;
    1782              : 
    1783            0 :       case M2Reserved_intok:
    1784            0 :         M2Printf_printf0 ((const char *) "intok", 5);
    1785            0 :         break;
    1786              : 
    1787            0 :       case M2Reserved_looptok:
    1788            0 :         M2Printf_printf0 ((const char *) "looptok", 7);
    1789            0 :         break;
    1790              : 
    1791            0 :       case M2Reserved_modtok:
    1792            0 :         M2Printf_printf0 ((const char *) "modtok", 6);
    1793            0 :         break;
    1794              : 
    1795            0 :       case M2Reserved_moduletok:
    1796            0 :         M2Printf_printf0 ((const char *) "moduletok", 9);
    1797            0 :         break;
    1798              : 
    1799            0 :       case M2Reserved_nottok:
    1800            0 :         M2Printf_printf0 ((const char *) "nottok", 6);
    1801            0 :         break;
    1802              : 
    1803            0 :       case M2Reserved_oftok:
    1804            0 :         M2Printf_printf0 ((const char *) "oftok", 5);
    1805            0 :         break;
    1806              : 
    1807            0 :       case M2Reserved_ortok:
    1808            0 :         M2Printf_printf0 ((const char *) "ortok", 5);
    1809            0 :         break;
    1810              : 
    1811            0 :       case M2Reserved_pointertok:
    1812            0 :         M2Printf_printf0 ((const char *) "pointertok", 10);
    1813            0 :         break;
    1814              : 
    1815            0 :       case M2Reserved_proceduretok:
    1816            0 :         M2Printf_printf0 ((const char *) "proceduretok", 12);
    1817            0 :         break;
    1818              : 
    1819            0 :       case M2Reserved_qualifiedtok:
    1820            0 :         M2Printf_printf0 ((const char *) "qualifiedtok", 12);
    1821            0 :         break;
    1822              : 
    1823            0 :       case M2Reserved_unqualifiedtok:
    1824            0 :         M2Printf_printf0 ((const char *) "unqualifiedtok", 14);
    1825            0 :         break;
    1826              : 
    1827            0 :       case M2Reserved_recordtok:
    1828            0 :         M2Printf_printf0 ((const char *) "recordtok", 9);
    1829            0 :         break;
    1830              : 
    1831            0 :       case M2Reserved_repeattok:
    1832            0 :         M2Printf_printf0 ((const char *) "repeattok", 9);
    1833            0 :         break;
    1834              : 
    1835            0 :       case M2Reserved_returntok:
    1836            0 :         M2Printf_printf0 ((const char *) "returntok", 9);
    1837            0 :         break;
    1838              : 
    1839            0 :       case M2Reserved_settok:
    1840            0 :         M2Printf_printf0 ((const char *) "settok", 6);
    1841            0 :         break;
    1842              : 
    1843            0 :       case M2Reserved_thentok:
    1844            0 :         M2Printf_printf0 ((const char *) "thentok", 7);
    1845            0 :         break;
    1846              : 
    1847            0 :       case M2Reserved_totok:
    1848            0 :         M2Printf_printf0 ((const char *) "totok", 5);
    1849            0 :         break;
    1850              : 
    1851            0 :       case M2Reserved_typetok:
    1852            0 :         M2Printf_printf0 ((const char *) "typetok", 7);
    1853            0 :         break;
    1854              : 
    1855            0 :       case M2Reserved_untiltok:
    1856            0 :         M2Printf_printf0 ((const char *) "untiltok", 8);
    1857            0 :         break;
    1858              : 
    1859            0 :       case M2Reserved_vartok:
    1860            0 :         M2Printf_printf0 ((const char *) "vartok", 6);
    1861            0 :         break;
    1862              : 
    1863            0 :       case M2Reserved_whiletok:
    1864            0 :         M2Printf_printf0 ((const char *) "whiletok", 8);
    1865            0 :         break;
    1866              : 
    1867            0 :       case M2Reserved_withtok:
    1868            0 :         M2Printf_printf0 ((const char *) "withtok", 7);
    1869            0 :         break;
    1870              : 
    1871            0 :       case M2Reserved_asmtok:
    1872            0 :         M2Printf_printf0 ((const char *) "asmtok", 6);
    1873            0 :         break;
    1874              : 
    1875            0 :       case M2Reserved_volatiletok:
    1876            0 :         M2Printf_printf0 ((const char *) "volatiletok", 11);
    1877            0 :         break;
    1878              : 
    1879            0 :       case M2Reserved_periodperiodperiodtok:
    1880            0 :         M2Printf_printf0 ((const char *) "periodperiodperiodtok", 21);
    1881            0 :         break;
    1882              : 
    1883            0 :       case M2Reserved_datetok:
    1884            0 :         M2Printf_printf0 ((const char *) "datetok", 7);
    1885            0 :         break;
    1886              : 
    1887            0 :       case M2Reserved_linetok:
    1888            0 :         M2Printf_printf0 ((const char *) "linetok", 7);
    1889            0 :         break;
    1890              : 
    1891            0 :       case M2Reserved_filetok:
    1892            0 :         M2Printf_printf0 ((const char *) "filetok", 7);
    1893            0 :         break;
    1894              : 
    1895            0 :       case M2Reserved_integertok:
    1896            0 :         M2Printf_printf0 ((const char *) "integertok", 10);
    1897            0 :         break;
    1898              : 
    1899            0 :       case M2Reserved_identtok:
    1900            0 :         M2Printf_printf0 ((const char *) "identtok", 8);
    1901            0 :         break;
    1902              : 
    1903            0 :       case M2Reserved_realtok:
    1904            0 :         M2Printf_printf0 ((const char *) "realtok", 7);
    1905            0 :         break;
    1906              : 
    1907            0 :       case M2Reserved_stringtok:
    1908            0 :         M2Printf_printf0 ((const char *) "stringtok", 9);
    1909            0 :         break;
    1910              : 
    1911              : 
    1912              :       default:
    1913              :         break;
    1914              :     }
    1915            0 : }
    1916              : 
    1917              : 
    1918              : /*
    1919              :    DumpTokens - displays all tokens.
    1920              : */
    1921              : 
    1922            0 : extern "C" void M2LexBuf_DumpTokens (void)
    1923              : {
    1924            0 :   unsigned int high;
    1925            0 :   unsigned int ind;
    1926              : 
    1927            0 :   if (Indexing_IsEmpty (ListOfTokens))
    1928              :     {
    1929            0 :       M2Printf_printf0 ((const char *) "The token buffer is empty\\n", 27);
    1930              :     }
    1931              :   else
    1932              :     {
    1933            0 :       ind = Indexing_LowIndice (ListOfTokens);
    1934            0 :       high = Indexing_HighIndice (ListOfTokens);
    1935            0 :       while (ind <= high)
    1936              :         {
    1937            0 :           M2Printf_printf1 ((const char *) "%5d ", 4, (const unsigned char *) &ind, (sizeof (ind)-1));
    1938            0 :           DumpToken (reinterpret_cast <M2LexBuf_TokenDesc> (Indexing_GetIndice (ListOfTokens, ind)));
    1939            0 :           ind += 1;
    1940              :         }
    1941              :     }
    1942            0 : }
    1943              : 
    1944        14952 : extern "C" void _M2_M2LexBuf_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    1945              : {
    1946        14952 :   Init ();
    1947        14952 : }
    1948              : 
    1949            0 : extern "C" void _M2_M2LexBuf_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    1950              : {
    1951            0 : }
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.