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

nasa / trick / 21296718347

23 Jan 2026 06:24PM UTC coverage: 55.589% (+0.009%) from 55.58%
21296718347

Pull #2031

github

web-flow
Merge 050505a97 into e4390df66
Pull Request #2031: Frame log choose buffering

8 of 9 new or added lines in 1 file covered. (88.89%)

172 existing lines in 8 files now uncovered.

12507 of 22499 relevant lines covered (55.59%)

308951.89 hits per line

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

67.86
/trick_source/sim_services/MemoryManager/ref_parser.y
1
%name-prefix="REF_"
2
%pure-parser
3
%locations
4
%parse-param {RefParseContext* context}
5
%lex-param { void* scanner }
6
%{
7

8
/*
9
   %debug
10
   %error-verbose
11
 */
12

13
#include <iostream>
14
#include <sstream>
15
#include <stdlib.h>
16
#include <string.h>
17

18
#include "trick/RefParseContext.hh"
19
#include "trick/vval.h"
20
#include "trick/value.h"
21
#include "trick/var.h"
22
#include "ref_parser.tab.hpp"
23

24
#pragma GCC diagnostic ignored "-Wunused-parameter"
25

26
    using namespace std;
27

28
    int REF_lex( YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner );
29
 
30
    void REF_error( YYLTYPE* locp, RefParseContext* context __attribute__ ((unused)) , const char* err) {
1✔
31
        std::stringstream message;
1✔
32
        message << "Syntax error: " << locp->first_line << " : " << err ;
1✔
33
        Trick::MemoryManager::emitError(message.str());
1✔
34
    }
1✔
35

36
#define scanner context->scanner
37
#ifdef YYDEBUG
38
#undef YYDEBUG
39
#endif
40
#define YYDEBUG 1
41
%}
42

43
%start reference
44

45
%union {
46
    char*  sval  ;
47
    int    ival  ;
48
    V_DATA vval ;
49
    REF2   rval ;
50
}
51

52
%token <sval> NAME 
53
%token <ival> I_CON
54

55
%token ARROW
56

57
%token END 0 "End of file"
58

59
%type  <vval> v_data 
60
%type  <rval> param reference 
61
%type  <ival> dereference 
62

63
%%
64

65
reference: param { 
66
        /*
67
         * This rule handles the collection of parameter name information.
68
         * When this rule fires the I->reference parameter, of type REF,
69
         * (same type used through io_* functions), is ready to be sent to
70
         * ref_attributes()
71
         */
72

73
          $$ = $1 ;
13,024✔
74
          context->result = (REF2*)malloc( sizeof(REF2));
13,024✔
75
          memcpy( context->result, &$1, sizeof(REF2));
13,024✔
76
}
77
;
78

79
param: NAME {
80
    /* 
81
     * This rule handles anything that starts with a NAME.  That includes
82
     * parameters, input file variables, defines, enumerations, and
83
     * sizeof structure types.
84
     * This first rule will return a reference if the variable is a
85
     * parameter or a variable.
86
     */
87

88
    int ret;
89

90
    $$.reference = NULL;
13,140✔
91
    $$.num_index = 0;
13,140✔
92
    $$.units = NULL;
13,140✔
93
    $$.pointer_present = 0;
13,140✔
94
    $$.stl_present = 0;
13,140✔
95
    $$.ref_type = REF_ADDRESS;
13,140✔
96
    $$.create_add_path = 1 ;
13,140✔
97
    $$.address_path = DLL_Create() ;
13,140✔
98

99
    // Get the address and attrs of the variable.
100
    if ((ret = context->mem_mgr->ref_var( &$$, $1)) != MM_OK) {
13,140✔
101
        return ( ret);
114✔
102
    }
103

104
    $$.num_index_left = $$.attr->num_index;
13,026✔
105
    $$.reference = $1 ;
13,026✔
106

107
}
108
| '&' NAME {
109
    /*
110
     * This rule handles the first name with a preceding address character.
111
     * Only parameters and vars are allowed to have a preceding "&" char.
112
     */
113

114
      int ret;
115

116
      $$.reference = NULL;
×
117
      $$.num_index = 0;
×
118
      $$.units = NULL;
×
119
      $$.pointer_present = 0;
×
120
      $$.stl_present = 0;
×
121
      $$.ref_type = REF_ADDRESS;
×
UNCOV
122
      $$.create_add_path = 1 ;
×
UNCOV
123
      $$.address_path = DLL_Create() ;
×
124

125
    // Get the address and attrs of the variable.
126
    if ((ret = context->mem_mgr->ref_var( &$$, $2)) != MM_OK) {
×
127
        std::stringstream message;
×
128
        message << "MemoryManager ERROR: Invalid reference: \"" << $2 << "\".";
×
UNCOV
129
        Trick::MemoryManager::emitError(message.str());
×
UNCOV
130
        return ( ret);
×
131
    }
132

UNCOV
133
    $$.num_index_left = $$.attr->num_index;
×
134
    //$$.reference = strdup($2) ;
135

136
}
137
| param '[' v_data ']' {
138

139
    int ret;
140

141
    if ((ret = context->mem_mgr->ref_dim(&$$, &$3)) != MM_OK) {
9,800✔
142
        return (ret);
1✔
143
    }
144

145
}
146
| param dereference NAME {
147

148
    /* This rule handles every name level after the first with a "->" or "." */
149
    int ret;
150
    char temp[512];
151

152
    if ( $2 == 1) {
2,509✔
153
        // we have an ARROW, so dereference the address.
154
        $$.address = *(void**)$$.address;
3✔
155
        $$.num_index ++; 
3✔
156
    }
157

158
    /* Check to see if previous parameter specified enough dimensions. */
159
    if ($$.num_index != $$.attr->num_index) {
2,509✔
160
        std::stringstream message;
×
161
        message << "Dimension mismatch.";
×
UNCOV
162
        Trick::MemoryManager::emitError(message.str());
×
UNCOV
163
        return (MM_PARAMETER_ARRAY_DIM);
×
164
    }
165

166
    $$.num_index = 0;
2,509✔
167

168
    if ((ret = context->mem_mgr->ref_name(&$$, $3)) != MM_OK) {
2,509✔
169
        return (ret);
1✔
170
    }
171

172
    /* create a new reference string because previous nodes may refer to old strings */
173
    $$.num_index_left = $$.attr->num_index;
2,508✔
174

175
    snprintf(temp, sizeof(temp), "%s.%s" , $$.reference, $3) ;
2,508✔
176

177
    $$.reference = (char*)realloc($$.reference, strlen(temp) + 1) ;
2,508✔
178
    strcpy($$.reference , temp) ;
2,508✔
179

180
    free($3);
2,508✔
181

182
} ;
183

184
dereference: ARROW {
185
        $$ = 1 ;
3✔
186
           }
187
           | '.' {
188
        $$ = 0 ;
2,506✔
189
           };
190

191
v_data:
192
    I_CON { 
193
        /*
194
         * Do not convert to double to ensure that there is no loss of precision
195
         */
196
        $$.value.i = $1 ;
9,800✔
197
        $$.type = TRICK_INTEGER ;
9,800✔
198
    }
199
    ;
200

201
%%
202

203

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