• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 25456501308

06 May 2026 07:29PM UTC coverage: 55.935% (-0.8%) from 56.7%
25456501308

Pull #2011

github

web-flow
Merge 7ad262960 into 7054e405e
Pull Request #2011: Single-file CI and code style adoption

14612 of 26123 relevant lines covered (55.94%)

462107.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.69
/trick_source/sim_services/CheckPointAgent/input_parser.l
1
%option prefix="CCP_"
2
%option reentrant
3
%option bison-bridge
4
%option bison-locations
5
%option yylineno
6
%option debug
7
%option noyywrap
8

9
%{
10
/*
11
 * This is a debug macro which is used to echo every character parsed by the
12
 * lex.
13
 */
14
#define PRINT if(I->verify_input || I->echo_input){printf("%s",yytext);}
15
#define PRINTRED PRINT
16
#define PRINTGREEN PRINT
17
#define PRINTYELLOW PRINT
18
#define PRINTBBLUE PRINT
19
#define PRINTBMAGENTA PRINT
20
#define PRINTCYAN PRINT
21
#define PRINT00
22

23
#include <stdio.h>
24
#include <stdlib.h>
25
#include <ctype.h>
26
#include "trick/mm_error.h"
27
#include "trick/ChkPtParseContext.hh"
28
#include "input_parser.tab.hpp"
29
#include "trick/TrickConstant.hh"
30

31
#define YY_EXTRA_TYPE ChkPtParseContext*
32

33
#define YY_USER_ACTION yylloc->first_line = yylineno;
34

35
#define YY_INPUT(buf, result, maxsize) \
36
{                                      \
37
    char c;                            \
38
    (*yyextra->is) >> std::noskipws >> c;   \
39
    if (yyextra->is->eof()) {          \
40
        result = YY_NULL;              \
41
    } else {                           \
42
        buf[0] = c;                    \
43
        result = 1;                    \
44
    }                                  \
45
}                                                
46

47
/*===== END OF INITIAL C SOURCE CODE SECTION =====*/
48
/*
49
 * Be careful where you put comments after this, lex doesn't like them
50
 * just anywhere. For example, the IBM needs each comment line to be its
51
 * own comment - no multi-line comments.
52
   FLOAT (((({D}+"."{D}*)|({D}*"."{D}+)){EXP}?)|({D}+{EXP}))
53

54
   FLOAT -?(((({D}+"."{D}*)|({D}*"."{D}+)){EXP}?)|({D}+{EXP}))
55
 */
56
/*=== LEXICAL SPECIFICATIONS ===*/
57

58
%}
59
%X QSTR
60
%X CPPCMT
61
%X CCOMMENT
62

63
W     [ \t]
64
Q     "\\\""
65
D     [0-9]
66
OCT   "0"[0-7]+
67
HEX   "0"[Xx][0-9a-fA-F]+
68
DHEX   "0"[Gg][0-9a-fA-F]+
69
EXP   ([Ee][-+]?{D}+)
70
FLOAT -?(((({D}+"."{D}*)|({D}*"."{D}+)){EXP}?)|({D}+{EXP}))
71
CHAR_OCTAL  "'\\"[0-7]+"'"  
72
CHAR_HEX    "'\\x"[a-fA-F0-9]+"'"  
73
NAM         [_a-zA-Z][_a-zA-Z0-9:]*
74
ENAM        [_a-zA-Z][_a-zA-Z0-9.]*
75
NAM2        [_a-zA-Z][-_a-zA-Z0-9.()\[\]/$#{}]*
76

77
ECHO_ON     [Ee][Cc][Hh][Oo][ \t_][Oo][Nn]
78
ECHO_OFF    [Ee][Cc][Hh][Oo][ \t_][Oo][Ff][Ff]
79

80
%%
81

82
 yy_flex_debug = 0;
83
 ChkPtParseContext * I = yyextra ;
158,810✔
84

158,810✔
85
"//" BEGIN CPPCMT ;
86
<CPPCMT>. ;
1,667✔
87
<CPPCMT>\n BEGIN 0 ;
1,667✔
88

43,295✔
89
"/*" { BEGIN(CCOMMENT); }
41,628✔
90
<CCOMMENT>{
11✔
91
   "*/" { BEGIN(0); }
1,678✔
92
   . {}
11✔
93
}
11✔
94
<QSTR>"\"" { 
11✔
95

451✔
96
   int l ; PRINTBMAGENTA ;
5,333✔
97
   /*
5,333✔
98
    * This rule picks up either 1) the closing double quote of a
99
    * string, or 2) an escaped quote within a string.
100
    */
101
   l = strlen( I->buf ) ;
102
   if( (l > 0) && (I->buf[ l - 1 ] == '\\') ) {
5,333✔
103
      /* If the previous character is a backslash then this is an
5,333✔
104
       * escaped quote, copy the character to the string buffer an
105
       * continue looking for the real closing quote.
106
       */
107
      I->buf[l-1] = '"' ;
108
   }
×
109
   else {
110
      /* else this is the real closing quote. Save off the
111
       * character string without the closing quote to the YACC
112
       * variable, switch the parsing state back to the normal
113
       * state and return a S_CON token to YACC
114
       */
115
      yylval->sval = strdup( I->buf ) ;
116
      BEGIN 0 ;
5,333✔
117
      return( S_CON ) ;
5,333✔
118
   }
5,333✔
119

120
}
121

122
<QSTR>"\\"  {
×
123

4✔
124
     char ch ; 
4✔
125
     PRINTRED ;
126
     (*yyextra->is) >> ch;
4✔
127
     switch ( ch ) {
4✔
128
        case 'b' :
4✔
129
           strcat ( I->buf , "\b" ) ;
×
130
           break ;
×
131
        case 't' :
×
132
           strcat ( I->buf , "\t" ) ;
×
133
           break ;
×
134
        case 'n' :
×
135
           strcat ( I->buf , "\n" ) ;
×
136
           break ;
×
137
        case 'v' :
×
138
           strcat ( I->buf , "\v" ) ;
×
139
           break ;
×
140
        case 'f' :
×
141
           strcat ( I->buf , "\f" ) ;
×
142
           break ;
×
143
        case 'r' :
×
144
           strcat ( I->buf , "\r" ) ;
×
145
           break ;
×
146
        case '\\' :
×
147
           strcat ( I->buf , "\\" ) ;
×
148
           break ;
×
149
        case '\'' :
×
150
           strcat ( I->buf , "\'" ) ;
×
151
           break ;
×
152
        case '\"' :
×
153
           strcat ( I->buf , "\"" ) ;
4✔
154
           break ;
4✔
155
     }
4✔
156
     if(I->verify_input || I->echo_input){printf("%c",ch);}
157

4✔
158
}
159

160
<QSTR>[^"\\]* {
4✔
161
   PRINTBMAGENTA ; 
5,319✔
162
   strcat( I->buf , (const char *)yytext ) ;
5,319✔
163
}
5,319✔
164

165

5,319✔
166
{ECHO_ON} {
×
167
   PRINT ;
×
168
   return( ECHO_ON ) ;
×
169
}
×
170

171
{ECHO_OFF} {
172
   PRINT ;
×
173
   return( ECHO_OFF ) ;
×
174
}
×
175

176
";" |
177
"," |
87,886✔
178
"&" |
179
"/" |
180
"*" |
181
"+" |
182
"=" |
183
"." |
184
"(" |
185
")" |
186
"{" |
187
"}" |
188
"[" |
189
"]" {
190
    PRINT;
191
    return( (int)yytext[0] );
87,886✔
192
}
87,886✔
193

194
alloc/{W}*\( {
195
   PRINT ;
×
196
   return( ALLOC ) ;
×
197
}
×
198

×
199
"char" {
×
200
   PRINTGREEN ;
22✔
201
   yylval->ival = TRICK_CHARACTER ;
22✔
202
   return( TYPE ) ;
22✔
203
}
22✔
204

205
"std::string" {
206
   PRINTGREEN ;
1,426✔
207
   yylval->ival = TRICK_STRING ;
1,426✔
208
   return( TYPE ) ;
1,426✔
209
}
1,426✔
210

211
"wchar" {
212
   PRINTGREEN ;
×
213
   yylval->ival = TRICK_WCHAR ;
×
214
   return( TYPE ) ;
×
215
}
×
216

217
"signed char" {
218
   PRINTGREEN ;
×
219
   yylval->ival = TRICK_CHARACTER ;
×
220
   return( TYPE ) ;
×
221
}
×
222

223
"unsigned char" {
224
   PRINTGREEN ;
×
225
   yylval->ival = TRICK_UNSIGNED_CHARACTER ;
×
226
   return( TYPE ) ;
×
227
}
×
228

229
"short" {
230
   PRINTGREEN ;
3✔
231
   yylval->ival = TRICK_SHORT ;
3✔
232
   return( TYPE ) ;
3✔
233
}
3✔
234

235
"signed short" {
236
   PRINTGREEN ;
×
237
   yylval->ival = TRICK_SHORT ;
×
238
   return( TYPE ) ;
×
239
}
×
240

241
"unsigned short" {
242
   PRINTGREEN ;
×
243
   yylval->ival = TRICK_UNSIGNED_SHORT ;
×
244
   return( TYPE ) ;
×
245
}
×
246

247
"int" {
248
   PRINTGREEN ;
88✔
249
   yylval->ival = TRICK_INTEGER ;
88✔
250
   return( TYPE ) ;
88✔
251
}
88✔
252

253
"signed int" {
254
   PRINTGREEN ;
×
255
   yylval->ival = TRICK_INTEGER ;
×
256
   return( TYPE ) ;
×
257
}
×
258

259
"unsigned int" {
260
   PRINTGREEN ;
1✔
261
   yylval->ival = TRICK_UNSIGNED_INTEGER ;
1✔
262
   return( TYPE ) ;
1✔
263
}
1✔
264

265
"long" {
266
   PRINTGREEN ;
1✔
267
   yylval->ival = TRICK_LONG ;
1✔
268
   return( TYPE ) ;
1✔
269
}
1✔
270

271
"signed long" {
272
   PRINTGREEN ;
×
273
   yylval->ival = TRICK_LONG ;
×
274
   return( TYPE ) ;
×
275
}
×
276

277
"unsigned long" {
278
   PRINTGREEN ;
×
279
   yylval->ival = TRICK_UNSIGNED_LONG ;
×
280
   return( TYPE ) ;
×
281
}
×
282

283
"long long" {
284
   PRINTGREEN ;
×
285
   yylval->ival = TRICK_LONG_LONG ;
×
286
   return( TYPE ) ;
×
287
}
×
288

289
"signed long long" {
290
   PRINTGREEN ;
×
291
   yylval->ival = TRICK_LONG_LONG ;
×
292
   return( TYPE ) ;
×
293
}
×
294

295
"unsigned long long" {
296
   PRINTGREEN ;
×
297
   yylval->ival = TRICK_UNSIGNED_LONG_LONG ;
×
298
   return( TYPE ) ;
×
299
}
×
300

301
"float" {
302
   PRINTGREEN ;
1✔
303
   yylval->ival = TRICK_FLOAT ;
1✔
304
   return( TYPE ) ;
1✔
305
}
1✔
306

307
"double" {
308
   PRINTGREEN ;
33✔
309
   yylval->ival = TRICK_DOUBLE ;
33✔
310
   return( TYPE ) ;
33✔
311
}
33✔
312

313
"FILE"{W}*\* {
314
   PRINTGREEN ;
×
315
   yylval->ival = TRICK_FILE_PTR ;
×
316
   return( TYPE ) ;
×
317
}
×
318

319
"bool" {
320
   PRINTGREEN ;
×
321
   yylval->ival = TRICK_BOOLEAN ;
×
322
   return( TYPE ) ;
×
323
}
×
324

325
"false" {  
326
  PRINTGREEN ;
1✔
327
  /*
1✔
328
   * This rule handles the c++ bool "false" value.
329
   */
330
  yylval->llval = 0 ;
331
  return( I_CON ) ;
1✔
332
}
1✔
333

334
"true" {  
335
   PRINTGREEN ;
1,799✔
336
   /*
1,799✔
337
    * This rule handles the c++ bool "true" value.
338
    */
339
   yylval->llval = 1 ;
340
   return( I_CON ) ;
1,799✔
341
}
1,799✔
342

343
"NULL" {
344
   PRINTBMAGENTA ;
×
345
   yylval->llval = 0 ;
×
346
   return( I_CON ) ;
×
347
}
×
348

349
{NAM} {
350
   /*
36,459✔
351
    * This rule handles general parameter and label names.
36,459✔
352
    * save the name in a YACC variable and return the token to YACC.
353
    */
354
   yylval->sval = strdup( yytext ) ;
355
   PRINT;
36,459✔
356
   return( NAME ) ;
36,459✔
357
}
36,459✔
358

359
{FLOAT} {
360
   PRINTBMAGENTA ;
1,629✔
361
   /*
1,629✔
362
    * This rule handles a floating point number. 
363
    * Convert the string to a floating point number, save the number in
364
    * a YACC variable and return the YACC token.
365
    */
366
   yylval->fval = atof( yytext );
367
   return( F_CON );
1,629✔
368
}
1,629✔
369

370
{OCT} { 
371
   long long i ; 
×
372
   PRINTBMAGENTA ;
×
373
   /*
×
374
    * This rule handles integers in octal format.
375
    * convert the string to an integer value, save the value in
376
    * the YACC variable and return the YACC token.
377
    */
378
   sscanf( yytext , "%llo" , &i ) ;
379
   yylval->llval = i ;
×
380
   return( I_CON ) ;
×
381
}
×
382

383
{HEX} {  
384
   long long i ;
×
385
   PRINTBMAGENTA ;
×
386
   /*
×
387
    * This rule handles integers in hexidecimal format.
388
    * convert the string to an integer value, save the value in
389
    * the YACC variable and return the YACC token.
390
    * The first two characters of yytext are the "0x" characters
391
    * which signify a hex number.
392
    */
393
   sscanf( &(yytext[2]) , "%llx" , &i ) ;
394
   yylval->llval = i ;
×
395
   return( I_CON ) ;
×
396
}
×
397

398
{DHEX} {  
399
   long long i ;
1✔
400
   PRINTBMAGENTA ;
1✔
401
   /*
1✔
402
    * This rule handles integers in doubles in hexidecimal format.
403
    * convert the string to an integer value, save the value in
404
    * the YACC variable and return the YACC token.
405
    * The first two characters of yytext are the "0d" characters
406
    * which signify a hex number.
407
    * save as a long long but return the type as double
408
    */
409
   sscanf( &(yytext[2]) , "%llx" , &i ) ;
410
   yylval->llval = i ;
1✔
411
   return( F_CON ) ;
1✔
412
}
1✔
413

414
-?{D}+ {
415
   PRINTBMAGENTA ;
23,398✔
416
   /*
23,398✔
417
    * This rule handles integers in decimal format.
418
    * convert the string to an integer value, save the value in
419
    * the YACC variable and return the YACC token.
420
    * Decimals can overflow for unsigned long longs so test to
421
    * see if we are over that and covert to unsigned if it's
422
    * greater that that huge number
423
    */
424
#if __APPLE__
425
   yylval->llval = strtoq( yytext, (char **)NULL, 10 );
426
#else
427
   yylval->llval = atoll( yytext );
428
#endif
23,398✔
429
   if (yylval->llval == TRICK_MAX_LONG_LONG) {
430
#if __APPLE__
23,398✔
431
      yylval->ullval = strtouq(yytext, (char **)NULL, 10);
432
#else
433
      yylval->ullval = strtoull(yytext, (char **)NULL, 10);
434
#endif
229✔
435
      return( UI_CON );
436
   }
229✔
437
   return( I_CON );
438
}
23,169✔
439

440
-- {
441
   return( DOUBLE_DASH );
×
442
}
×
443

444
"'"."'" {
445
    PRINTBMAGENTA ;
440✔
446
   /*
440✔
447
    * This rule matches any character enclosed in single quotes.
448
    * this is used for character assignments.
449
    * save the character in the YACC variable and return the YACC
450
    * token.
451
    */
452
   yylval->cval = yytext[1] ;
453
   return( C_CON );
440✔
454
}
440✔
455

456
{CHAR_OCTAL} {
457
   unsigned i ;
×
458
   PRINTBMAGENTA ;
×
459
   /*
×
460
    * This rule handles character assignments where the character is
461
    * specified by its octal integer value. Convert the octal string
462
    * to an integer value and then save the integer value as a
463
    * chracter in the YACC variable, then return the YACC token.
464
    */
465
   sscanf(&(yytext[2]),"%o",&i);
466
   yylval->cval = (char)i ;
×
467
   return( C_CON );
×
468
}
×
469

470
{CHAR_HEX} {
471
   unsigned i ;
265✔
472
   PRINTBMAGENTA ;
265✔
473
   sscanf(&(yytext[3]),"%x",&i);
265✔
474
   yylval->cval = (char)i ;
265✔
475
   return( C_CON );
265✔
476
}
265✔
477

478
"'\\n'" {
479
   PRINTBMAGENTA ;
×
480
   /*
×
481
    * This rule handles newline character assignments.
482
    */
483
   yylval->cval = '\n' ;
484
   return( C_CON );
×
485
}
×
486

487
"'\\t'" {
488
   PRINTBMAGENTA ;
×
489
   /*
×
490
    * This rule handles tab character assignments.
491
    */
492
   yylval->cval = '\t' ;
493
   return( C_CON );
×
494
}
×
495

496
"'\\\\'" {
497
   PRINTBMAGENTA ;
×
498
   /*
×
499
    * This rule handles backslash, '\', character assignments.
500
    */
501
   yylval->cval = '\\' ;
502
   return( C_CON );
×
503
}
×
504

505
"\"" {
506
   PRINTBMAGENTA ;
5,333✔
507
   /*
5,333✔
508
    * This is the start of a string in double quotes, throw away
509
    * the quote character (by not saving it anywhere) initialize
510
    * a I->buffer to hold the string, and switch the parsing state to a
511
    * the string only parsing state.
512
    */
513
   I->buf[0] = '\0' ;
514
   BEGIN QSTR ;
5,333✔
515
}
5,333✔
516

517
\n {
5,333✔
518
   PRINT ;
22,627✔
519
   /*
22,627✔
520
    * This rule handles all other newlines.
22,627✔
521
    */
522
   //I->file.lineno++ ;
523
}
524

525
[ \t]+ { PRINT } ; /* whitespace */
22,627✔
526

39,011✔
527
<QSTR><<EOF>> {
78,022✔
528
   /* This is an unterminated string */
×
529
   I->error_str = I->buf ;
530
   return(MM_UNTERMINATED_STRING) ;
×
531
}
×
532

533
<<EOF>> {
534
   yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner ) ;
24✔
535
   return( 0 );
24✔
536
}
24✔
537

538
. {
539
   /*
×
540
    * This rule matches all other characters not matched by a previous
×
541
    * rule. All lex synatx error messages are handled by the rule.
542
    * Starting at the unrecognized character, all remaining characters
543
    * to the end of the current line or the end of the file are read
544
    * and stored in a buffer which is then used as part of the syntax
545
    * error message. I->token is an input processor parameter designed
546
    * specifically for use with error messages.
547
    */
548
   I->error_str = yytext ;
549
   I->save_str_pos = yytext ;
×
550
   return(MM_SYNTAX_ERROR) ;
×
551
}
×
552

553

554
%%
×
555

×
556

×
557
void ChkPtParseContext::init_scanner() {
558

24✔
559
    // Allocate the scanner structure.
560
    yylex_init( &scanner);
561

24✔
562
    // Set the file where output messages are to go.
563
    yyset_out( stdout, scanner);
564
    yyset_extra( this, scanner);
24✔
565

24✔
566
}
567

24✔
568
void ChkPtParseContext::destroy_scanner() {
569

24✔
570
    yylex_destroy(scanner);
571

24✔
572
}
573

24✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc