Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
trace.c
Go to the documentation of this file.
1 /* *************************************************************************************
2  Copyright (c) 2021, Lowell D. Thomas
3  All rights reserved.
4 
5  This file is part of APG Version 7.0.
6  APG Version 7.0 may be used under the terms of the BSD 2-Clause License.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 
14  2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 * *************************************************************************************/
36 #include "./apg.h"
37 #ifdef APG_TRACE
38 #include "../utilities/utilities.h"
39 #include "./parserp.h"
40 #include "./tracep.h"
41 
42 static void vUp(trace* spCtx, const opcode* spOp, aint uiState, aint uiOffset, aint uiPhraseLength);
43 static void vDown(trace* spCtx, const opcode* spOp, aint uiOffset);
44 static abool bTraceConfigCheck(trace* spCtx, const opcode* spOp);
45 #ifndef APG_NO_PPPT
46 static void vDownPppt(trace* spCtx, const opcode* spOp, aint uiOffset){
47  aint uiState = uiPpptState(spCtx->spParserCtx, spOp, uiOffset);
48  if(uiState == ID_ACTIVE){
49  vDown(spCtx, spOp, uiOffset);
50  }else{
51  if (bTraceConfigCheck(spCtx, spOp)) {
52  spCtx->iTraceDepth++;
53  trace_record sRecord = {};
54  if (spCtx->iTraceDepth < spCtx->iTraceDepthMin) {
55  spCtx->iTraceDepthMin = spCtx->iTraceDepth;
56  }
57  sRecord.uiTreeDepth = spCtx->uiTreeDepth;
58  sRecord.iTraceDepth = spCtx->iTraceDepth;
59  sRecord.uiThisRecord = spCtx->uiThisRecord;
60  sRecord.uiState = uiState;
61  sRecord.uiOffset = uiOffset;
62  sRecord.uiPhraseLength = (uiState == ID_MATCH) ? 1 : 0;
63  sRecord.spOpcode = spOp;
64  vDisplayRecord(spCtx, &sRecord, APG_TRUE);
65  spCtx->uiThisRecord++;
66  }
67  spCtx->uiTreeDepth++;
68  if (spCtx->uiTreeDepth > spCtx->uiTreeDepthMax) {
69  spCtx->uiTreeDepthMax = spCtx->uiTreeDepth;
70  }
71  }
72 }
73 static void vUpPppt(trace* spCtx, const opcode* spOp, aint uiState, aint uiOffset, aint uiPhraseLength){
74  aint uiPrevState = uiPpptState(spCtx->spParserCtx, spOp, uiOffset);
75  if(uiPrevState == ID_ACTIVE){
76  vUp(spCtx, spOp, uiState, uiOffset, uiPhraseLength);
77  }else{
78  spCtx->uiTreeDepth--;
79  if (bTraceConfigCheck(spCtx, spOp)) {
80  spCtx->iTraceDepth--;
81  }
82  }
83 }
84 #endif
85 
86 
92 void* vpTraceCtor(void* vpCtx) {
93  if(!bParserValidate(vpCtx)){
94  vExContext();
95  }
96  parser* spParser = (parser*) vpCtx;
97  if(spParser->vpTrace){
98  vTraceDtor(spParser->vpTrace);
99  spParser->vpTrace = NULL;
100  }
101  void* vpMem = spParser->vpMem;
102  trace* spTrace = (trace*) vpMemAlloc(vpMem, (aint) sizeof(trace));
103  memset((void*) spTrace, 0, sizeof(trace));
104  spTrace->vpMem = vpMem;
105  spTrace->spException = spMemException(vpMem);
106  spTrace->spParserCtx = spParser;
107 
108  // open the display file
109  spTrace->spOut = stdout;
110  spTrace->cpFileName = NULL;
111  spTrace->vpVecFileName = vpVecCtor(vpMem, sizeof(char), 1024);
112 
113  // lookaround stack
114  spTrace->vpLookaroundStack = vpVecCtor(spTrace->vpMem, (aint) sizeof(aint), 500);
115 
116  // get space to configure individual rules
117  spTrace->sConfig.bpRules = (abool*) vpMemAlloc(spTrace->vpMem,
118  (aint) (sizeof(abool) * spTrace->spParserCtx->uiRuleCount));
119  memset((void*) spTrace->sConfig.bpRules, 0, sizeof(abool) * spTrace->spParserCtx->uiRuleCount);
120  if (spTrace->spParserCtx->uiUdtCount) {
121  // get space to configure individual UDTS
122  spTrace->sConfig.bpUdts = (abool*) vpMemAlloc(spTrace->vpMem,
123  (aint) (sizeof(abool) * spTrace->spParserCtx->uiUdtCount));
124  memset((void*) spTrace->sConfig.bpUdts, 0, sizeof(abool) * spTrace->spParserCtx->uiUdtCount);
125  }
126  // get space to configure individual operators (ALT, CAT, etc., NOTE: ID_GEN must be > all other ids)
127  spTrace->sConfig.bpOps = (abool*) vpMemAlloc(spTrace->vpMem, (aint) (sizeof(abool) * ID_GEN));
128  memset((void*) spTrace->sConfig.bpOps, 0, sizeof(abool) * ID_GEN);
129 
130  // get buffer for constructing display strings
131  spTrace->uiBufSize = 4096;
132  spTrace->cpBuf = (char*) vpMemAlloc(spTrace->vpMem, (aint) (sizeof(char) * spTrace->uiBufSize));
133  memset((void*) spTrace->cpBuf, 0, (sizeof(char) * spTrace->uiBufSize));
134 
135  // set default config to all rules, UDTs, ops and records
136  vSetDefaultConfig(spTrace);
137 
138  // success
139  spParser->vpTrace = (void*) spTrace;
140  return (void*)spTrace;
141 }
142 
152 void vTraceDtor(void* vpCtx){
153  trace* spTrace = (trace*) vpCtx;
154  if (spTrace) {
155  if(!bParserValidate(spTrace->spParserCtx)){
156  vExContext();
157  }
158  if(spTrace->spOut && (spTrace->spOut != stdout)){
159  fclose(spTrace->spOut);
160  spTrace->spOut = NULL;
161  }
162  if(spTrace->spOpenFile && (spTrace->spOpenFile != stdout)){
163  fclose(spTrace->spOpenFile);
164  spTrace->spOpenFile = NULL;
165  }
166  vVecDtor(spTrace->vpVecFileName);
167  vMsgsDtor(spTrace->vpLog);
168  spTrace->spParserCtx->vpTrace = NULL;
169  }
170 }
171 
172 void vTraceSetOutput(void* vpCtx, const char* cpFileName){
173  trace* spTrace = (trace*) vpCtx;
174  if(!bParserValidate(spTrace->spParserCtx)){
175  vExContext();
176  }
177  vVecClear(spTrace->vpVecFileName);
178  if(spTrace->spOut && spTrace->spOut != stdout){
179  fclose(spTrace->spOut);
180  }
181  spTrace->spOut = stdout;
182  spTrace->cpFileName = NULL;
183  if(cpFileName){
184  spTrace->cpFileName = (char*)vpVecPushn(spTrace->vpVecFileName, NULL, (strlen(cpFileName) + 1));
185  strcpy(spTrace->cpFileName, cpFileName);
186  spTrace->spOut = fopen(spTrace->cpFileName, "wb");
187  if(!spTrace->spOut){
188  char caBuf[1024];
189  snprintf(caBuf, 1024, "can't open file %s for trace output", cpFileName);
190  XTHROW(spTrace->spException, caBuf);
191  }
192  }
193 }
194 
199 void vTraceApgexHeader(void* vpCtx){
200  trace* spCtx = (trace*) vpCtx;
201  if(!bParserValidate(spCtx->spParserCtx)){
202  vExContext();
203  }
204  spCtx->uiThisRecord = 0;
205  vDisplayHeader(spCtx);
206 }
211 void vTraceApgexFooter(void* vpCtx){
212  trace* spCtx = (trace*) vpCtx;
213  if(!bParserValidate(spCtx->spParserCtx)){
214  vExContext();
215  }
216  vDisplayFooter(spCtx);
217  fflush(spCtx->spOut);
218 }
219 
225 void vTraceApgexSeparator(void* vpCtx, aint uiLastIndex){
226  trace* spCtx = (trace*) vpCtx;
227  if(!bParserValidate(spCtx->spParserCtx)){
228  vExContext();
229  }
230  vDisplaySeparator(spCtx, uiLastIndex);
231 }
232 
237 void vTraceBegin(void* vpCtx){
238  trace* spCtx = (trace*) vpCtx;
239  if(!bParserValidate(spCtx->spParserCtx)){
240  vExContext();
241  }
242  spCtx->uiThisRecord = 0;
244  vDisplayHeader(spCtx);
245  }
246 }
251 void vTraceEnd(void* vpCtx){
252  trace* spCtx = (trace*) vpCtx;
253  if(!bParserValidate(spCtx->spParserCtx)){
254  vExContext();
255  }
257  vDisplayFooter(spCtx);
258  fflush(spCtx->spOut);
259  }
260 }
265 #ifdef APG_NO_PPPT
266 void vTraceDown(void* vpCtx, const opcode* spOp, aint uiOffset){
267  trace* spCtx = (trace*) vpCtx;
268  vDown(spCtx, spOp, uiOffset);
269 }
270 #else
271 void vTraceDown(void* vpCtx, const opcode* spOp, aint uiOffset){
272  trace* spCtx = (trace*) vpCtx;
273  if(spCtx->sConfig.bPppt){
274  vDownPppt(spCtx, spOp, uiOffset);
275  }else{
276  vDown(spCtx, spOp, uiOffset);
277  }
278 }
279 #endif
280 
284 #ifdef APG_NO_PPPT
285 void vTraceUp(void* vpCtx, const opcode* spOp, aint uiState, aint uiOffset, aint uiPhraseLength){
286  trace* spCtx = (trace*) vpCtx;
287  vUp(spCtx, spOp, uiState, uiOffset, uiPhraseLength);
288 }
289 #else
290 void vTraceUp(void* vpCtx, const opcode* spOp, aint uiState, aint uiOffset, aint uiPhraseLength){
291  trace* spCtx = (trace*) vpCtx;
292  if(spCtx->sConfig.bPppt){
293  vUpPppt(spCtx, spOp, uiState, uiOffset, uiPhraseLength);
294  }else{
295  vUp(spCtx, spOp, uiState, uiOffset, uiPhraseLength);
296  }
297 }
298 #endif
299 
309  trace* spCtx = (trace*) vpCtx;
310  if(!bParserValidate(spCtx->spParserCtx)){
311  vExContext();
312  }
313  return spCtx->uiThisRecord;
314 }
315 
316 static void vDown(trace* spCtx, const opcode* spOp, aint uiOffset){
317  trace_record sRecord = {};
318  aint uiId;
319  if (bTraceConfigCheck(spCtx, spOp)) {
320  if(spOp->sGen.uiId == ID_NOT || spOp->sGen.uiId == ID_AND){
321  uiId = ID_LOOKAROUND_AHEAD;
322  vpVecPush(spCtx->vpLookaroundStack, (void*) &uiId);
323  }else if(spOp->sGen.uiId == ID_BKA || spOp->sGen.uiId == ID_BKN){
324  uiId = ID_LOOKAROUND_BEHIND;
325  vpVecPush(spCtx->vpLookaroundStack, (void*) &uiId);
326  }
327  sRecord.uiTreeDepth = spCtx->uiTreeDepth;
328  sRecord.iTraceDepth = spCtx->iTraceDepth;
329  sRecord.uiThisRecord = spCtx->uiThisRecord;
330  sRecord.spOpcode = spOp;
331  sRecord.uiOffset = uiOffset;
332  sRecord.uiPhraseLength = 0;
333  sRecord.uiState = (aint) ID_ACTIVE;
334  vDisplayRecord(spCtx, &sRecord, APG_FALSE);
335  spCtx->uiThisRecord++;
336  spCtx->iTraceDepth++;
337  if (spCtx->iTraceDepth > spCtx->iTraceDepthMax) {
338  spCtx->iTraceDepthMax = spCtx->iTraceDepth;
339  }
340  }
341  spCtx->uiTreeDepth++;
342  if (spCtx->uiTreeDepth > spCtx->uiTreeDepthMax) {
343  spCtx->uiTreeDepthMax = spCtx->uiTreeDepth;
344  }
345 }
346 static void vUp(trace* spCtx, const opcode* spOp, aint uiState, aint uiOffset, aint uiPhraseLength) {
347  trace_record sRecord = {};
348  spCtx->uiTreeDepth--;
349  if (bTraceConfigCheck(spCtx, spOp)) {
350  spCtx->iTraceDepth--;
351  if (spCtx->iTraceDepth < spCtx->iTraceDepthMin) {
352  spCtx->iTraceDepthMin = spCtx->iTraceDepth;
353  }
354  if(spOp->sGen.uiId == ID_NOT || spOp->sGen.uiId == ID_AND ||
355  spOp->sGen.uiId == ID_BKA || spOp->sGen.uiId == ID_BKN){
356  vpVecPop(spCtx->vpLookaroundStack);
357  }
358  sRecord.uiTreeDepth = spCtx->uiTreeDepth;
359  sRecord.iTraceDepth = spCtx->iTraceDepth;
360  sRecord.uiThisRecord = spCtx->uiThisRecord;
361  sRecord.spOpcode = spOp;
362  sRecord.uiOffset = uiOffset;
363  sRecord.uiPhraseLength = uiPhraseLength;
364  sRecord.uiState = (aint) uiState;
365  vDisplayRecord(spCtx, &sRecord, APG_FALSE);
366  spCtx->uiThisRecord++;
367  }
368 }
369 static abool bTraceConfigCheck(trace* spCtx, const opcode* spOp) {
370  abool bReturn = APG_FALSE;
371  trace_config* spConfig = &spCtx->sConfig;
372  aint uiId = spOp->sGen.uiId;
373  switch(uiId){
374  case ID_ALT:
375  case ID_CAT:
376  case ID_REP:
377  case ID_TRG:
378  case ID_TLS:
379  case ID_TBS:
380  case ID_AND:
381  case ID_NOT:
382  case ID_BKR:
383  case ID_BKA:
384  case ID_BKN:
385  case ID_ABG:
386  case ID_AEN:
387  bReturn = spConfig->bpOps[uiId];
388  break;
389  case ID_RNM:
390  bReturn = spConfig->bpRules[spOp->sRnm.spRule->uiRuleIndex];
391  break;
392  case ID_UDT:
393  bReturn = spConfig->bpUdts[spOp->sUdt.spUdt->uiUdtIndex];
394  break;
395  }
396  if(spConfig->bCountOnly){
397  // count the record but don't print it (inhibits vDown and vTraceUP)
398  if(bReturn){
399  spCtx->uiThisRecord++;
400  bReturn = APG_FALSE;
401  }
402  }else{
403  if(bReturn){
404  if(spCtx->uiThisRecord < spConfig->uiFirstRecord){
405  // haven't reached the first record to print yet
406  spCtx->uiThisRecord++;
407  bReturn = APG_FALSE;
408  }else{
409  if(spConfig->uiMaxRecords < (spCtx->uiThisRecord - spConfig->uiFirstRecord)){
410  // have already printed the maximum number of records allowed
411  spCtx->uiThisRecord++;
412  bReturn = APG_FALSE;
413  }
414  }
415  }
416  }
417  return bReturn;
418 }
419 
420 #endif /* APG_TRACE */
vTraceSetOutput
void vTraceSetOutput(void *vpCtx, const char *cpFileName)
Definition: trace.c:172
apg.h
The APG header file.
vTraceApgexFooter
void vTraceApgexFooter(void *vpCtx)
Only called by apgex.
Definition: trace.c:211
trace::spParserCtx
parser * spParserCtx
Pointer back to the parent parser's context.
Definition: tracep.h:95
ID_LOOKAROUND_BEHIND
#define ID_LOOKAROUND_BEHIND
the parser presently is in look behind mode
Definition: parser.h:111
vDisplaySeparator
void vDisplaySeparator(trace *spCtx, aint uiLastIndex)
Display a separator between trace outputs (apgex only)
Definition: trace-out.c:129
trace::iTraceDepthMax
int iTraceDepthMax
The maximum (possibly partial) traced node depth.
Definition: tracep.h:105
ID_RNM
#define ID_RNM
rule name
Definition: parser.h:46
trace::spOut
FILE * spOut
Pointer to the open output file.
Definition: tracep.h:98
trace_record::uiThisRecord
aint uiThisRecord
The record index of the current record.
Definition: tracep.h:63
parserp.h
Private header for the SABNF parser.
vDisplayFooter
void vDisplayFooter(trace *spCtx)
Display the trace footer.
Definition: trace-out.c:141
trace_record::uiPhraseLength
aint uiPhraseLength
The phrase length of a successful match.
Definition: tracep.h:65
trace_config
Configuration defining the subset of nodes to display information for.
Definition: tracep.h:73
vVecDtor
void vVecDtor(void *vpCtx)
The vector component destructor.
Definition: vector.c:161
trace_record::spOpcode
const opcode * spOpcode
Pointer to the opcode for the current node.
Definition: tracep.h:67
ID_ALT
#define ID_ALT
alternation
Definition: parser.h:43
vTraceBegin
void vTraceBegin(void *vpCtx)
Called by the parser to start the trace.
Definition: trace.c:237
ID_BKR
#define ID_BKR
back reference to a previously matched rule or UDT name
Definition: parser.h:58
ID_UDT
#define ID_UDT
user-defined terminal
Definition: parser.h:55
trace::spOpenFile
FILE * spOpenFile
Pointer to any other open file.
Definition: tracep.h:99
vExContext
void vExContext()
Handles bad context pointers.
Definition: exception.c:126
trace_config::bPppt
abool bPppt
However, no records are actually displayed.
Definition: tracep.h:85
trace_config::bpUdts
abool * bpUdts
An array of true/false indicators for each UDT in the SABNF grammar.
Definition: tracep.h:75
trace::uiThisRecord
aint uiThisRecord
Index of the current trace record.
Definition: tracep.h:101
trace_config::uiMaxRecords
aint uiMaxRecords
Maximun number of records to display.
Definition: tracep.h:80
vTraceApgexSeparator
void vTraceApgexSeparator(void *vpCtx, aint uiLastIndex)
Only called by apgex.
Definition: trace.c:225
trace::vpLookaroundStack
void * vpLookaroundStack
Pointer to a stack require to keep track of when tracing in look around mode.
Definition: tracep.h:100
ID_NOT
#define ID_NOT
negative look ahead
Definition: parser.h:57
ID_AND
#define ID_AND
positive look ahead
Definition: parser.h:56
trace_config::bpOps
abool * bpOps
An array of true/false indicators for each opcode in the SABNF grammar.
Definition: tracep.h:76
trace::sConfig
trace_config sConfig
Pointer to the trace configuration.
Definition: tracep.h:110
vTraceUp
void vTraceUp(void *vpCtx, const opcode *spOp, aint uiState, aint uiOffset, aint uiPhraseLength)
Called by the parser following upward traversal of a parse tree node.
Definition: trace.c:285
trace_record::uiState
aint uiState
The parser's state for this node (ID_ACTIVE, ID_MATCH, etc.)
Definition: tracep.h:66
XTHROW
#define XTHROW(ctx, msg)
Exception throw macro.
Definition: exception.h:67
vpVecPop
void * vpVecPop(void *vpCtx)
Pops one element from the end of the array.
Definition: vector.c:250
vTraceDtor
void vTraceDtor(void *vpCtx)
Trace destructor.
Definition: trace.c:152
trace::iTraceDepthMin
int iTraceDepthMin
The minimum (possibly partial) traced node depth.
Definition: tracep.h:106
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
spMemException
exception * spMemException(void *vpCtx)
Get a pointer to this memory objects's exception handler.
Definition: memory.c:174
vpTraceCtor
void * vpTraceCtor(void *vpCtx)
The trace object constructor.
Definition: trace.c:92
trace_record::iTraceDepth
int iTraceDepth
The partial parse tree depth (a subset possibly restricted by the configuration.)
Definition: tracep.h:62
ID_CAT
#define ID_CAT
concatenation
Definition: parser.h:44
vpMemAlloc
void * vpMemAlloc(void *vpCtx, aint uiBytes)
Allocates memory.
Definition: memory.c:196
trace_record::uiTreeDepth
aint uiTreeDepth
The actual parse tree depth.
Definition: tracep.h:61
vpVecCtor
void * vpVecCtor(void *vpMem, aint uiElementSize, aint uiInitialAlloc)
The vector object constructor.
Definition: vector.c:118
ID_TRG
#define ID_TRG
terminal range
Definition: parser.h:47
trace::uiTreeDepth
aint uiTreeDepth
The current full parse tree depth.
Definition: tracep.h:102
ID_REP
#define ID_REP
repetition
Definition: parser.h:45
ID_LOOKAROUND_AHEAD
#define ID_LOOKAROUND_AHEAD
the parser presently is in look ahead mode
Definition: parser.h:110
ID_ACTIVE
#define ID_ACTIVE
indicates active parser state, parser has just entered the node and is moving down the parse tree
Definition: parser.h:72
vMsgsDtor
void vMsgsDtor(void *vpCtx)
The object destructor.
Definition: msglog.c:92
ID_MATCH
#define ID_MATCH
indicates a matched phrase parser state on return from parse tree below this node
Definition: parser.h:73
vpVecPushn
void * vpVecPushn(void *vpCtx, void *vpElement, aint uiCount)
Adds one or more elements to the end of the array.
Definition: vector.c:221
ID_BKA
#define ID_BKA
positive look behind
Definition: parser.h:59
trace_config::uiHeaderType
aint uiHeaderType
Indicates whether the trace is being done by apgex.
Definition: tracep.h:78
ID_GEN
#define ID_GEN
general opcode (not SABNF). Serves to locate the ID in any opcode structure and must be larger than a...
Definition: parser.h:63
vTraceApgexHeader
void vTraceApgexHeader(void *vpCtx)
Only called by apgex.
Definition: trace.c:199
tracep.h
Private header file for the trace functions.
ID_TLS
#define ID_TLS
terminal literal string
Definition: parser.h:49
APG_TRUE
#define APG_TRUE
Definition: apg.h:291
trace_record
The information recorded & displayed by the trace object for each node visited.
Definition: tracep.h:60
vTraceEnd
void vTraceEnd(void *vpCtx)
Called by the parser to end the trace.
Definition: trace.c:251
trace::cpFileName
char * cpFileName
Name of the file to display the trace records to.
Definition: tracep.h:96
ID_BKN
#define ID_BKN
negative look behind
Definition: parser.h:60
uiTraceGetRecordCount
aint uiTraceGetRecordCount(void *vpCtx)
Get the number of traced records, displayed or not.
Definition: trace.c:308
abool
uint8_t abool
abool is the APG bool type.
Definition: apg.h:140
trace_config::bpRules
abool * bpRules
An array of true/false indicators for each rule in the SABNF grammar.
Definition: tracep.h:74
trace::iTraceDepth
int iTraceDepth
The current (possibly partial) traced node depth.
Definition: tracep.h:104
TRACE_HEADER_TRACE
#define TRACE_HEADER_TRACE
Identifies the trace object as the header handler.
Definition: tracep.h:54
trace::uiTreeDepthMax
aint uiTreeDepthMax
The maximum full parse tree depth achieved.
Definition: tracep.h:103
ID_ABG
#define ID_ABG
anchor - beginning of string
Definition: parser.h:61
trace::vpVecFileName
void * vpVecFileName
Vector to allocate and re-allocate the memory for the file name.
Definition: tracep.h:97
vDisplayRecord
void vDisplayRecord(trace *spCtx, trace_record *spRec, abool bIsMatchedPppt)
Display one trace record.
Definition: trace-out.c:110
trace
The trace object context. Maintains the trace object's state.
Definition: tracep.h:91
trace_config::uiFirstRecord
aint uiFirstRecord
Number of the first record to display.
Definition: tracep.h:79
ID_TBS
#define ID_TBS
terminal binary string
Definition: parser.h:48
vTraceDown
void vTraceDown(void *vpCtx, const opcode *spOp, aint uiOffset)
Called by the parser prior to downward traversal of a parse tree node.
Definition: trace.c:266
trace_record::uiOffset
aint uiOffset
The offset into the input string for the first character of the sub-phrase being matched.
Definition: tracep.h:64
trace_config::bCountOnly
abool bCountOnly
If true, trace will only count the number of records that would have been displayed.
Definition: tracep.h:83
vpVecPush
void * vpVecPush(void *vpCtx, void *vpElement)
Adds one element to the end of the array.
Definition: vector.c:193
bParserValidate
abool bParserValidate(void *vpCtx)
Validate the context pointer of a parser.
Definition: parser.c:422
trace::vpLog
void * vpLog
Pointer to a message log object for reporting configuration errors.
Definition: tracep.h:94
vVecClear
void vVecClear(void *vpCtx)
Clears all used elements in a vector component.
Definition: vector.c:420
trace::spException
exception * spException
Pointer to the exception to use to report fatal errors back to the parser's catch block.
Definition: tracep.h:93
vDisplayHeader
void vDisplayHeader(trace *spCtx)
Display the trace header.
Definition: trace-out.c:98
vSetDefaultConfig
void vSetDefaultConfig(trace *spTrace)
Sets the default trace configuration on construction.
Definition: trace-config.c:56
ID_AEN
#define ID_AEN
anchor - end of string
Definition: parser.h:62
APG_FALSE
#define APG_FALSE
Definition: apg.h:292
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.