EnglishРусский  

   ..

   alias.c

   alias.h

   bcodes.c

   bcodes.h

   body.c

   compile.c

   compile.h

   define.c

   define.h

   desc.c

   expr.c

   extern.c

   for.c

   foreach.c

   func.c

   func.h

   global.c

   global.h

   goto.c

   if.c

   ifdef.c

   ifdef.h

   import.c

   import.h

   include.c

   include.h

   jump.c

   lexem.c

   lexem.h

   macro.c

   macro.h

   operlist.txt

   out.c

   out.h

   subfunc.c

   switch.c

   type.c

   type.h

   vars.c

   while.c

   with.c

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

 1 /******************************************************************************
 2 *
 3 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
 4 * This file is part of the Gentee open source project - http://www.gentee.com. 
 5 * 
 6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
 7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
 8 * ACCEPTANCE OF THE AGREEMENT.
 9 *
10 * ID: ifdef 18.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 * Summary: ifdef command
15 *
16 ******************************************************************************/
17 
18 #include "ifdef.h"
19 #include "macro.h"
20 
21 /*-----------------------------------------------------------------------------
22 *
23 * ID: ifdef 22.11.06 0.0.A.
24 * 
25 * Summary: define command
26 *
27 -----------------------------------------------------------------------------*/
28 
29 plexem  STDCALL ifdef( plexem plex )
30 {
31    plexem    start = plex;
32    plexem    exp;
33    uint      ok;
34    uint      found = 0;
35    pmacrores lexval;
36    uint      bvalue;
37 
38 lelif:
39    exp = plex;
40 //   plex->type = LEXEM_SKIP;  // delete 'ifdef' or 'elif'
41 
42    plex = lexem_next( macroexpr( lexem_next( plex, LEXNEXT_IGNLINE ), 
43                       &lexval ), LEXNEXT_SKIPLINE );
44    bvalue = lexval->bvalue;
45    if ( (int)bvalue == -1 )
46       msg( MWrongname | MSG_LEXNAMEERR, lexem_next( exp, LEXNEXT_IGNLINE ));
47 
48    if ( !found )
49       found = bvalue;
50    else
51       bvalue = 0;
52 
53    while ( exp < plex ) // delete 'ifdef' or 'elif' and все лексемы в выражении
54    {
55       exp->type = LEXEM_SKIP;
56       exp++;
57    }
58 //   print("Lexval=%i %i\n", lexval->bvalue, lexval->vallexem.num.vint  );
59 lelse:
60    ok = 1;
61 
62    // SKIP LINE чтобы plex оставался прежним
63    // Можн заменить простой проверкой на LCURLY ?
64    plex = lexem_next( plex,  LEXNEXT_SKIPLINE | LEXNEXT_LCURLY );
65    plex->type = LEXEM_SKIP; // LCURLY
66    while ( ok )
67    {
68       // Why was 'bvalue ? 0 : '?
69       plex = lexem_next( plex,  /*bvalue ? 0 : */LEXNEXT_NOMACRO );
70       if ( lexem_isys( plex, LSYS_LCURLY ) || lexem_isys( plex, LSYS_COLLECT ))
71          ok++;
72       if ( lexem_isys( plex, LSYS_RCURLY ))
73          ok--;
74       if ( !bvalue )
75          plex->type = LEXEM_SKIP;
76    }
77    plex->type = LEXEM_SKIP;   // RCURLY
78 
79    plex = lexem_next( plex, LEXNEXT_SKIPLINE );
80 
81    if ( plex->type == LEXEM_KEYWORD )
82    {
83       if ( plex->key == KEY_ELIF )
84          goto lelif;
85 
86       if ( plex->key == KEY_ELSE )
87       {
88          bvalue = !found;
89          plex->type = LEXEM_SKIP;
90          plex = lexem_next( plex, LEXNEXT_SKIPLINE );
91          goto lelse;
92       }
93    }
94    return start;
95 }
96 
97