1 /******************************************************************************
2 *
3 * Copyright (C) 2006, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: msglist 20.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 * Summary: The program generates msglist.h and msglist.с files
15 *
16 ******************************************************************************/
17
18 include : $"..\..\lib\gt\gt.g"
19 include : $"..\bytecode\cmdlist.g"
20
21 /*-----------------------------------------------------------------------------
22 *
23 * ID: msglist_h 12.10.06 1.1.A.
24 *
25 * Summary: The .h output function.
26 *
27 -----------------------------------------------------------------------------*/
28 text msglist_h( arrstr acmd, arrstr cmt )
29 \@headerout( "msglist_h", "Generated with 'msglist' program",
30 "This file contains a list of the compiler's or VM's messages.")
31 #ifndef _MSGLIST_
32 #define _MSGLIST_
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif // __cplusplus
37
38 #include "../common/types.h"
39
40 extern char* msgtext[];
41
42 #define MSGCOUNT \( *acmd )
43
44 enum {
45 \{
46 uint i
47
48 fornum i, *acmd
49 {
50 @" \(acmd[ i ] ), // 0x\( hex2stru( i )) \(i) \( cmt[i] )\l"
51 }
52 }
53 };
54
55 #ifdef __cplusplus
56 }
57 #endif // __cplusplus
58
59 #endif // _MSGLIST_
60 \!
61
62 /*-----------------------------------------------------------------------------
63 *
64 * ID: msglist_c 12.10.06 1.1.A.
65 *
66 * Summary: The .c output function.
67 *
68 -----------------------------------------------------------------------------*/
69
70 text msglist_c( arrstr pattern, arrstr acmd )
71 \@headerout( "msglist_c", "Generated with 'msglist' program", "")
72
73 const char* msgtext[] = {
74 \{
75 uint i
76
77 fornum i, *pattern
78 {
79 @" \"\( pattern[i] )\", // \( acmd[i] )\l"
80 }
81 }
82 };
83 \!
84
85 /*-----------------------------------------------------------------------------
86 *
87 * ID: msgmain 12.10.06 1.1.A.ABKL
88 *
89 * Summary: The main function.
90 *
91 -----------------------------------------------------------------------------*/
92
93 func msgmain<main>
94 {
95 arrstr aout
96 arrstr cmt
97 arrstr pattern
98 str hout
99 gt msggt
100 // gtitems gtis
101
102 msggt.read( "msglist.gt" )
103 foreach cur, msggt.root() //.items( gtis )
104 {
105 cur as gtitem
106 if cur.comment : continue
107 str stemp pat
108 aout += cur.name
109 cur.get("comment", stemp )
110 cmt += stemp
111 cur.get("pattern", pat )
112 pattern += ?( *pat, pat, stemp )
113 }
114 hout@msglist_h( aout, cmt )
115 hout.write( "msglist.h" )
116 hout.clear()
117 hout@msglist_c( pattern, aout )
118 hout.write( "msglist.c" )
119 congetch("Press any key...")
120 }
121
Редактировать