Version 6.3
Copyright © 2005 - 2012 Lowell D. Thomas
APG
  … ABNF Parser Generator
All Data Structures Files Functions Variables Typedefs Macros Pages
ApgUtilities.h
Go to the documentation of this file.
1 /*******************************************************************************
2  APG Version 6.3
3  Copyright (C) 2005 - 2012 Lowell D. Thomas, all rights reserved
4 
5  author: Lowell D. Thomas
6  email: lowell@coasttocoastresearch.com
7  website: http://www.coasttocoastresearch.com
8 
9  This program is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 2 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see
21  <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
22  or write to the Free Software Foundation, Inc.,
23  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 *******************************************************************************/
25 
26 #ifndef _ApgUtilities_h_16_6_2006_16_21_
27 #define _ApgUtilities_h_16_6_2006_16_21_
28 
35 #include "Apg.h"
36 #include "Private.h"
37 #include "Grammar.h"
38 #include <stdio.h>
39 #include <time.h>
40 
41 // Begin C-language linkage specification
42 #if defined(__cplusplus)
43 extern "C"
44 {
45 #endif
46 
47 // used exclusively to maintain conformance in printf %lu integer formats
52 typedef unsigned long int printf_uint;
53 
55 // FILE HELPERS
57 apg_uint uiGetFileSize(const char* cpFileName);
58 apg_uint uiGetFile(const char* cpFileName, void* vpBuffer);
59 apg_uint uiWriteFile(const char* cpFileName, void* vpData, apg_uint uiDataLen);
60 //apg_uint uiRenameFile(const char* cpFileName);
62 void vJavaScriptApgBytes(FILE* in, FILE* out);
65 // ALERTS
68 // alert handler that prints the alert state and terminates
69 void vTerminalAlert(unsigned int uiLine, const char* cpFile);
70 void vTerminalAlertMsg(unsigned int uiLine, const char* cpFile, const char* cpMsg);
71 
73 // TIMER
75 
76 #define APG_TIMER_SEC 1.0
77 #define APG_TIMER_MILLISEC 1000.0
78 #define APG_TIMER_MICROSEC 1000000.0
79 
80 void* vpTimerCtor(void* vpMemCtx);
81 void vTimerDtor(void* vpCtx);
82 apg_uint uiTimerStart(void* vpCtx);
83 apg_uint uiTimerStop(void* vpCtx);
84 
85 // uiConversion = desired units / second
86 // or desired unit = seconds * uiConversion
87 double dTimerStartTime(void* vpCtx, double dConversion);
88 double dTimerStopTime(void* vpCtx, double dConversion);
89 double dTimerDuration(void* vpCtx, double dConversion);
90 apg_uint uiTimerRates(void* vpCtx, double* dpRates, apg_uint uiLen, double dConversion);
91 
93 // STATS
95 void vDisplayMemStats(void* vpCtx);
96 void vDisplayOperatorStats(FILE* spOut, APG_PARSER_STATS* spStats);
97 void vDisplayRuleStats(FILE* spOut, APG_PARSER_STATS* spStats, const char* cpType);
98 
100 // STATES & STATS
102 void vDisplayParserState(FILE* spOut, void* vpParserCtx);
103 void vDisplayState(FILE* spOut, APG_PARSER_STATE* spState);
104 apg_uint uiAstToXml(FILE* spOut, void* vpParserCtx);
105 
107 // MISC
109 void vDisplayOpcodes(void* vpCtx);
110 void vDisplayAstRecords(FILE* spOut, void* vpParserCtx);
111 void vDisplayRules(void* vpParserCtx);
112 void vDisplayUdts(void* vpParserCtx);
113 const char* cpState2String(apg_uint uiState);
114 const char* cpBoolean2String(apg_uint uiBool);
115 
116 
117 // print file with one-based line numbers
118 void vDisplayAscii(FILE* spOut, const char* cpSrc, apg_uint uiSrcLen);
119 // prints the list of error locations in the error queue
120 void vLicenseNotice(FILE* spFile);
121 // print type sizes
122 void vDisplayTypeSizes(FILE* spOut);
123 void vDisplayGrammarInfo(FILE* spOut, void* vpHdr);
124 
125 // NOTE: can't access APG_PARSER_CTX from here, but don't lose this code
126 // it may come in handy another day
127 // prints a human-readable list of the parser's opcodes
128 //void vPrintOpcodes(APG_PARSER_CTX* spCtx);
129 // prints a human-readable display of the rule list
130 //void vPrintRuleList(APG_PARSER_CTX* spCtx);
131 // prints an ASCII string as string of 2-digit hexidecimal
132 //void vHexString(char* cpBuffer, apg_uint uiBufLen, char* cpString, apg_uint uiLen);
133 
134 // End C-language linkage specification
135 #if defined(__cplusplus)
136 }
137 #endif
138 
139 #endif // _ApgUtilities_h_16_6_2006_16_21_
dTimerDuration
double dTimerDuration(void *vpCtx, double dConversion)
Definition: timer.c:237
vDisplayAscii
void vDisplayAscii(FILE *spOut, const char *cpSrc, apg_uint uiSrcLen)
Definition: Utilities.c:62
vDisplayParserState
void vDisplayParserState(FILE *spOut, void *vpParserCtx)
Definition: Utilities.c:373
vDisplayRules
void vDisplayRules(void *vpParserCtx)
uiTimerStop
apg_uint uiTimerStop(void *vpCtx)
Definition: timer.c:117
APG_PARSER_STATS
full set of statistics gathered during parsing, uiParserSyntaxAnalysis()
Definition: Apg.h:591
APG_PARSER_STATE
the state of the parser after parsing an input string.
Definition: Apg.h:561
cpBoolean2String
const char * cpBoolean2String(apg_uint uiBool)
Definition: Utilities.c:605
vTimerDtor
void vTimerDtor(void *vpCtx)
Definition: timer.c:80
vDisplayMemStats
void vDisplayMemStats(void *vpCtx)
apg_uint
unsigned int apg_uint
Definition: Apg.h:169
dTimerStartTime
double dTimerStartTime(void *vpCtx, double dConversion)
Definition: timer.c:185
uiTimerStart
apg_uint uiTimerStart(void *vpCtx)
Definition: timer.c:96
vDisplayState
void vDisplayState(FILE *spOut, APG_PARSER_STATE *spState)
Definition: Utilities.c:391
uiGetFileSize
apg_uint uiGetFileSize(const char *cpFileName)
Definition: Files.c:40
vDisplayGrammarInfo
void vDisplayGrammarInfo(FILE *spOut, void *vpHdr)
Definition: Utilities.c:409
uiTimerRates
apg_uint uiTimerRates(void *vpCtx, double *dpRates, apg_uint uiLen, double dConversion)
Definition: timer.c:151
vDisplayUdts
void vDisplayUdts(void *vpParserCtx)
vDisplayAstRecords
void vDisplayAstRecords(FILE *spOut, void *vpParserCtx)
Definition: Utilities.c:183
vDisplayOpcodes
void vDisplayOpcodes(void *vpCtx)
Definition: Utilities.c:153
vDisplayOperatorStats
void vDisplayOperatorStats(FILE *spOut, APG_PARSER_STATS *spStats)
Definition: Utilities.c:296
Apg.h
Required header file for all APG-generated parsers. Contains important configuration macros and decla...
uiWriteFile
apg_uint uiWriteFile(const char *cpFileName, void *vpData, apg_uint uiDataLen)
Definition: Files.c:108
vDisplayRuleStats
void vDisplayRuleStats(FILE *spOut, APG_PARSER_STATS *spStats, const char *cpType)
Definition: Utilities.c:338
vpTimerCtor
void * vpTimerCtor(void *vpMemCtx)
Definition: timer.c:51
vLicenseNotice
void vLicenseNotice(FILE *spFile)
Definition: Utilities.c:442
printf_uint
unsigned long int printf_uint
Definition: ApgUtilities.h:52
uiAstToXml
apg_uint uiAstToXml(FILE *spOut, void *vpParserCtx)
Definition: Utilities.c:479
uiGetFile
apg_uint uiGetFile(const char *cpFileName, void *vpBuffer)
Definition: Files.c:71
vTerminalAlert
void vTerminalAlert(unsigned int uiLine, const char *cpFile)
Definition: Utilities.c:557
vTerminalAlertMsg
void vTerminalAlertMsg(unsigned int uiLine, const char *cpFile, const char *cpMsg)
Definition: Utilities.c:569
vDisplayTypeSizes
void vDisplayTypeSizes(FILE *spOut)
Definition: Utilities.c:279
cpState2String
const char * cpState2String(apg_uint uiState)
Definition: Utilities.c:590
dTimerStopTime
double dTimerStopTime(void *vpCtx, double dConversion)
Definition: timer.c:211
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/licenses.html or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.