Skip to content

Commit 549e729

Browse files
committed
Allow GPRE keywords in C++ expressions with the internal lang
1 parent 90b3bd7 commit 549e729

1 file changed

Lines changed: 69 additions & 1 deletion

File tree

src/gpre/par.cpp

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#ifdef FTN_BLK_DATA
6161
static void block_data_list(const gpre_dbb*);
6262
#endif
63+
static bool is_gpre_action_context();
6364
static bool match_parentheses();
6465
static act* par_any();
6566
static act* par_array_element();
@@ -141,6 +142,13 @@ act* PAR_action(const TEXT* base_dir)
141142
gpreGlob.token_global.tok_keyword <= KW_end_actions)
142143
{
143144
const kwwords_t keyword = gpreGlob.token_global.tok_keyword;
145+
146+
if (!is_gpre_action_context())
147+
{
148+
gpreGlob.token_global.tok_symbol = NULL;
149+
return NULL;
150+
}
151+
144152
if (! gpreGlob.sw_no_qli)
145153
{
146154
switch (keyword)
@@ -1253,6 +1261,67 @@ static void block_data_list( const gpre_dbb* db)
12531261
#endif
12541262

12551263

1264+
//____________________________________________________________
1265+
//
1266+
// In Firebird's internal C++ preprocessor mode, GPRE action
1267+
// keywords may also appear as regular C++ identifiers. Treat
1268+
// them as commands only where a standalone embedded command can
1269+
// reasonably start.
1270+
//
1271+
1272+
static bool is_gpre_action_context()
1273+
{
1274+
if (gpreGlob.sw_language != lang_internal)
1275+
return true;
1276+
1277+
switch (gpreGlob.token_global.tok_keyword)
1278+
{
1279+
case KW_L_BRACE:
1280+
case KW_R_BRACE:
1281+
return true;
1282+
1283+
default:
1284+
break;
1285+
}
1286+
1287+
if (gpreGlob.token_global.tok_first)
1288+
{
1289+
switch (gpreGlob.prior_token.tok_keyword)
1290+
{
1291+
case KW_EQUALS:
1292+
case KW_COMMA:
1293+
case KW_DOT:
1294+
case KW_POINTS:
1295+
case KW_LEFT_PAREN:
1296+
case KW_L_BRCKET:
1297+
case KW_PLUS:
1298+
case KW_MINUS:
1299+
case KW_ASTERISK:
1300+
case KW_SLASH:
1301+
return false;
1302+
1303+
default:
1304+
return true;
1305+
}
1306+
}
1307+
1308+
switch (gpreGlob.prior_token.tok_keyword)
1309+
{
1310+
case KW_none:
1311+
return !gpreGlob.prior_token.tok_symbol && gpreGlob.prior_token.tok_length == 0;
1312+
1313+
case KW_SEMI_COLON:
1314+
case KW_L_BRACE:
1315+
case KW_R_BRACE:
1316+
case KW_RIGHT_PAREN:
1317+
return true;
1318+
1319+
default:
1320+
return false;
1321+
}
1322+
}
1323+
1324+
12561325
//____________________________________________________________
12571326
//
12581327
//
@@ -3334,4 +3403,3 @@ static bool terminator()
33343403

33353404
return false;
33363405
}
3337-

0 commit comments

Comments
 (0)