Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/profile.syn @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 { | |
2 /* | |
3 * AnaGram, A System for Syntax Directed Programming | |
4 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
5 * Copyright 2006 David A. Holland. All Rights Reserved. | |
6 * See the file COPYING for license and usage terms. | |
7 * | |
8 * profile.syn - parse the "profile" (Windows registry entry / .AnaGram file) | |
9 */ | |
10 | |
11 #include "port.h" | |
12 | |
13 #include "agcstack.h" | |
14 #include "cint.h" | |
15 #include "ctrlpanel.hpp" | |
16 #include "dspar.hpp" | |
17 #include "profile-defs.h" | |
18 #include "version.h" | |
19 | |
20 //#define INCLUDE_LOGGING | |
21 #include "log.h" | |
22 } | |
23 | |
24 registry data $ | |
25 -> registry entry?..., "endInitializationData"?, eof | |
26 | |
27 eof = 0 | |
28 | |
29 sep = '/' + '-' | |
30 name char = ~eof - '\n' - '\r' - '=' - '.' | |
31 file name char = ~eof - '\n' -'\r' | |
32 digit = '0-9' | |
33 letter = 'a-z' + 'A-Z' | |
34 byte = 0..255 | |
35 | |
36 [ | |
37 test file mask = "*.prf" | |
38 //pointer input | |
39 event driven | |
40 parser name = parseRegEntry | |
41 parser file name = "#.cpp" | |
42 line numbers path = "regent.syn" | |
43 ] | |
44 | |
45 (void) registry entry | |
46 -> qualified registry entry | |
47 -> pure registry entry | |
48 | |
49 (void) qualified registry entry | |
50 -> accepted qualifier, pure registry entry | |
51 -> unaccepted qualifier, file name char..., '\n' | |
52 | |
53 (void) pure registry entry | |
54 -> ag201 registry entry | |
55 //-> ag240 registry entry // none yet | |
56 | |
57 (void) ag201 registry entry | |
58 -> "Color:", name, '=', color pair:p, '\n' = | |
59 ColorDialog::initColor(charStack.popString(), p); | |
60 -> "Font:", field id:id, '=', | |
61 font flags:f, integer:p, '.', | |
62 name, '\n' = | |
63 FontDialog::initFont(id, f,p, charStack.popString()); | |
64 -> "Autobuild=", integer:i, '\n' = controlPanel->autobuildFlag = i; | |
65 -> "ShowStatistics=", integer:i, '\n' = controlPanel->showStatsFlag = i; | |
66 -> "ShowSyntax=", integer:i, '\n' = controlPanel->showSyntaxFlag = i; | |
67 -> "StayOnTop=", integer:i, '\n' = controlPanel->stayOnTopFlag = i; | |
68 -> "cpLoc=", point:p,'\n' = controlPanelLocation = p; | |
69 -> "sfRect=", rectangle:r,'\n' = syntaxFileRect = r; | |
70 -> "Version=", integer:i,'\n' = lastVersion = i; | |
71 -> "RecentFile:", file name,'\n' = | |
72 { | |
73 LOGSECTION("RecentFile"); | |
74 LOGV(controlPanel->recentFiles.size()); | |
75 //controlPanel->recentFiles << charStack.popString(); | |
76 controlPanel->recentFiles.push(charStack.popString()); | |
77 LOGV(controlPanel->recentFiles.size()); | |
78 } | |
79 | |
80 (void) accepted qualifier, unaccepted qualifier | |
81 -> '(', qual expr:t, ')' = { if (!t) CHANGE_REDUCTION(unaccepted_qualifier); } | |
82 | |
83 (int) qual expr | |
84 -> integer:v1 = (INTVERSION == v1); | |
85 -> integer:v1, '-' = (INTVERSION >= v1); | |
86 -> integer:v1, '-', integer:v2 = (INTVERSION >= v1 && INTVERSION <= v2); | |
87 | |
88 (int) font flags | |
89 -> = 0; | |
90 -> font flags:f, 'B' = f|FontSpec::bold; | |
91 -> font flags:f, 'I' = f|FontSpec::italic; | |
92 -> font flags:f, 'S' = f|FontSpec::strikeout; | |
93 -> font flags:f, 'U' = f|FontSpec::underscore; | |
94 | |
95 name | |
96 -> name char:c = charStack.discardData().push(c); | |
97 -> name, name char:c = charStack.push(c); | |
98 | |
99 (int) field id | |
100 -> name = FontDialog::idField(charStack.popString()); | |
101 | |
102 (int) integer | |
103 -> digit:d = d - '0'; | |
104 -> integer:i, digit:d = 10*i + d - '0'; | |
105 | |
106 (int) signed integer | |
107 -> integer | |
108 -> '-', integer:i = -i; | |
109 | |
110 (int) hex integer | |
111 -> hex digit:d = d; | |
112 -> hex integer:i, hex digit:d = 16*i + d; | |
113 | |
114 (int) hex digit | |
115 -> digit:d = d-'0'; | |
116 -> 'a-f' + 'A-F':d = (d&7) + 9; | |
117 | |
118 (cint) color pair | |
119 -> '(', hex integer:f, ',', hex integer:g, ')' = cint(f, g); | |
120 | |
121 (IPoint) point | |
122 -> '(', signed integer:f, ',', signed integer:g, ')' = IPoint(f, g); | |
123 | |
124 (IRectangle) rectangle | |
125 -> '(', integer:a,',', integer:b,',', integer:c,',', integer:d, ')' = | |
126 IRectangle(a, b, c, d); | |
127 | |
128 | |
129 file name | |
130 -> file name char:c = charStack.discardData().push(c); | |
131 -> file name, file name char:c = charStack.push(c); | |
132 | |
133 { | |
134 | |
135 int lastVersion = 200; | |
136 | |
137 static AgCharStack charStack; | |
138 | |
139 #ifndef SYNTAX_ERROR | |
140 #define SYNTAX_ERROR {\ | |
141 char buf[500];\ | |
142 sprintf(buf,"%s, line %d, column %d\n", \ | |
143 (PCB).error_message, (PCB).line, (PCB).column);\ | |
144 LOGV(buf);\ | |
145 } | |
146 #endif | |
147 | |
148 int initializeFrom(const char *pointer) { | |
149 LOGSECTION("initializeFrom"); | |
150 | |
151 if (pointer == 0) { | |
152 return 1; | |
153 } | |
154 init_parseRegEntry(); | |
155 do { | |
156 PCB.input_code = (unsigned char) *pointer; | |
157 parseRegEntry(); | |
158 } | |
159 while (*pointer++ && PCB.exit_flag == AG_RUNNING_CODE); | |
160 return PCB.exit_flag != AG_SUCCESS_CODE; | |
161 } | |
162 } |