Changeset 129
- Timestamp:
- Dec 19, 2017, 4:56:34 PM (7 years ago)
- Location:
- branches/generator
- Files:
-
- 1 added
- 20 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormGrammer.lfm
r124 r129 7 7 ClientHeight = 346 8 8 ClientWidth = 548 9 DesignTimePPI = 120 9 10 OnShow = FormShow 10 LCLVersion = '1. 6.4.0'11 LCLVersion = '1.8.0.6' 11 12 object Label1: TLabel 12 13 Left = 15 -
branches/generator/Forms/UFormGrammer.pas
r126 r129 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 U Rules;9 UGrammer; 10 10 11 11 type -
branches/generator/Forms/UFormMain.lfm
r128 r129 7 7 ClientHeight = 653 8 8 ClientWidth = 1050 9 DesignTimePPI = 120 9 10 Menu = MainMenu1 10 11 OnClose = FormClose 11 12 OnCloseQuery = FormCloseQuery 12 13 OnShow = FormShow 13 LCLVersion = '1. 6.4.0'14 LCLVersion = '1.8.0.6' 14 15 object MemoBNF: TMemo 15 16 Left = 0 … … 80 81 Height = 22 81 82 Top = 0 82 Width = 883 83 Style = tbsSeparator 84 84 end -
branches/generator/Forms/UFormMain.pas
r127 r129 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 Menus, ActnList, ComCtrls, UPersistentForm, U Rules;9 Menus, ActnList, ComCtrls, UPersistentForm, UGrammer; 10 10 11 11 type … … 77 77 78 78 uses 79 UFormRules, UCore, UFormGrammer ;79 UFormRules, UCore, UFormGrammer, UBuilder; 80 80 81 81 resourcestring … … 189 189 190 190 procedure TFormMain.ABuildCompilerExecute(Sender: TObject); 191 begin 192 Core.Grammer.BuildCompiler; 191 var 192 Builder: TBuilder; 193 begin 194 Builder := TBuilder.Create; 195 try 196 Builder.Grammer := Core.Grammer; 197 Builder.BuildCompiler; 198 finally 199 FreeAndNil(Builder); 200 end; 193 201 end; 194 202 -
branches/generator/Forms/UFormRule.lfm
r122 r129 8 8 ClientHeight = 514 9 9 ClientWidth = 663 10 DesignTimePPI = 120 10 11 OnCreate = FormCreate 11 12 OnDestroy = FormDestroy 12 13 OnShow = FormShow 13 LCLVersion = '1. 6.4.0'14 LCLVersion = '1.8.0.6' 14 15 object ButtonOk: TButton 15 16 Left = 376 … … 94 95 TabOrder = 4 95 96 end 97 object Label2: TLabel 98 Left = 312 99 Height = 20 100 Top = 52 101 Width = 37 102 Caption = 'Lavel:' 103 ParentColor = False 104 end 105 object ComboBoxLevel: TComboBox 106 Left = 376 107 Height = 28 108 Top = 48 109 Width = 125 110 ItemHeight = 20 111 Style = csDropDownList 112 TabOrder = 5 113 end 96 114 end -
branches/generator/Forms/UFormRule.pas
r126 r129 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ActnList, Menus, U Rules, UFormRuleItems;9 ComCtrls, ActnList, Menus, UGrammer, UFormRuleItems; 10 10 11 11 type … … 17 17 ButtonCancel: TButton; 18 18 CheckBoxCreateNode: TCheckBox; 19 ComboBoxLevel: TComboBox; 19 20 EditName: TEdit; 20 21 Label1: TLabel; 22 Label2: TLabel; 21 23 ListView1: TListView; 22 24 PageControl1: TPageControl; … … 70 72 71 73 procedure TFormRule.FormCreate(Sender: TObject); 74 var 75 I: TRuleLevel; 72 76 begin 73 77 FormRuleItems := TFormRuleItems.Create(nil); … … 76 80 FormRuleItems.Show; 77 81 UsedByRules := TStringList.Create; 82 ComboBoxLevel.Items.Clear; 83 for I := Low(TRuleLevel) to High(RuleLevelText) do 84 ComboBoxLevel.Items.Add(RuleLevelText[I]); 78 85 end; 79 86 … … 91 98 EditName.Text := Rule.Name; 92 99 CheckBoxCreateNode.Checked := Rule.CreateSourceNode; 100 ComboBoxLevel.ItemIndex := Integer(Rule.Level); 93 101 FormRuleItems.LoadData(Rule.Items); 94 102 end; … … 99 107 Rule.Name := EditName.Text; 100 108 Rule.CreateSourceNode := CheckBoxCreateNode.Checked; 109 Rule.Level := TRuleLevel(ComboBoxLevel.ItemIndex); 101 110 FormRuleItems.SaveData(Rule.Items); 102 111 end; -
branches/generator/Forms/UFormRuleItem.lfm
r123 r129 7 7 ClientHeight = 400 8 8 ClientWidth = 656 9 DesignTimePPI = 120 9 10 OnClose = FormClose 10 11 OnCreate = FormCreate 11 12 OnDestroy = FormDestroy 12 13 OnShow = FormShow 13 LCLVersion = '1. 6.4.0'14 LCLVersion = '1.8.0.6' 14 15 object ButtonCancel: TButton 15 16 Left = 176 -
branches/generator/Forms/UFormRuleItem.pas
r126 r129 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, U Rules;9 ComCtrls, UGrammer; 10 10 11 11 type -
branches/generator/Forms/UFormRuleItems.lfm
r128 r129 7 7 ClientHeight = 467 8 8 ClientWidth = 636 9 DesignTimePPI = 120 9 10 OnCreate = FormCreate 10 11 OnShow = FormShow 11 LCLVersion = '1. 6.4.0'12 LCLVersion = '1.8.0.6' 12 13 object ListView1: TListView 13 14 Left = 8 … … 96 97 object MenuItem1: TMenuItem 97 98 Action = AAdd 98 Bitmap.Data = {99 36040000424D3604000000000000360000002800000010000000100000000100100 2000000000000004000064000000640000000000000000000000000000000000101 0000000000000000000000000000000000000000000000000000000000000000102 0000000000000000000000000000000000000000000000000000000000000000103 000000000000000000000000000000000000D4D4D4FFB2B2B2FFB2B2B2FFD4D4104 D4FF000000000000000000000000000000000000000000000000000000000000105 0000000000000000000000000000709B70FF004A00FF004800FF4E764EFFB2B2106 B2FF000000000000000000000000000000000000000000000000000000000000107 0000000000000000000000000000004E00FF00C800FF00C400FF004800FFB2B2108 B2FF000000000000000000000000000000000000000000000000000000000000109 0000000000000000000000000000005000FF00CA00FF00C600FF004A00FFB2B2110 B2FF000000000000000000000000000000000000000000000000000000000000111 0000000000000000000000000000005300FF00CE00FF00CA00FF004C00FFB2B2112 B2FF00000000000000000000000000000000000000000000000000000000D4D4113 D4FFB2B2B2FFB2B2B2FFB2B2B2FF005400FF00D200FF00CE00FF004E00FFB2B2114 B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFD4D4D4FF0000000070A670FF005E115 00FF005C00FF005A00FF005800FF005600FF00D600FF00D000FF005000FF004E116 00FF004C00FF004A00FF004A00FF4E764EFFB2B2B2FF00000000006200FF8CFE117 8CFF00EA00FF00E600FF00E200FF00DE00FF00DA00FF00D400FF00D000FF00CC118 00FF00C800FF00C400FF00C200FF004800FFB2B2B2FF00000000006400FFECFF119 ECFF8CFE8CFF8CFE8CFF8CFE8CFF8CFE8CFF00DE00FF00D900FF00D400FF00D0120 00FF00CC00FF00C800FF00C400FF004A00FFD4D4D4FF0000000070A970FF0064121 00FF006400FF006200FF006000FF006000FF8CFE8CFF00DD00FF005800FF0056122 00FF005400FF005300FF005000FF709C70FF0000000000000000000000000000123 0000000000000000000000000000006000FF8CFE8CFF00E000FF005A00FFB2B2124 B2FF000000000000000000000000000000000000000000000000000000000000125 0000000000000000000000000000006200FF8CFE8CFF00E500FF005C00FFB2B2126 B2FF000000000000000000000000000000000000000000000000000000000000127 0000000000000000000000000000006400FF8CFE8CFF00E800FF005E00FFB2B2128 B2FF000000000000000000000000000000000000000000000000000000000000129 0000000000000000000000000000006400FFECFFECFF8CFE8CFF006000FFD4D4130 D4FF000000000000000000000000000000000000000000000000000000000000131 000000000000000000000000000070A970FF006400FF006200FF70A670FF0000132 0000000000000000000000000000000000000000000000000000133 }134 99 end 135 100 object MenuItem2: TMenuItem 136 101 Action = AModify 137 Bitmap.Data = {138 36040000424D3604000000000000360000002800000010000000100000000100139 2000000000000004000064000000640000000000000000000000986B37FF976A140 36FF966935FF966734FF956633FF946532FF946531FF936430FF92622FFF9261141 2EFF91602DFF90602CFF905F2BFF8F5D2AFF8E5C29FF8D5B28FF996C38FFF8F7142 F6FFF8F7F5FFF7F6F5FFF6F6F4FFF6F5F3FFF5F5F3FFF5F4F2FFF4F3F1FFF4F3143 F1FFF3F2F0FFF3F2EFFFF2F1EFFFF2F0EEFFF1F0EDFF8E5D29FF996D3AFFF9F8144 F7FF959594FF878787FF9B9A9AFFF7F6F4FFF6F5F3FFF6F5F3FFF5F4F2FFF4F3145 F1FFF4F3F1FFF3F2F0FFF3F2EFFFF2F1EFFFF2F1EEFF8F5E2AFF9A6E3BFFF9F9146 F8FF7C7C7CFFC4C4C4FF878787FFF7F6F5FF7A7A7AFF787878FF747474FF7171147 70FF6D6D6CFF696968FF656565FF616161FFF2F1EFFF905F2BFF9B6F3CFFFAF9148 F8FFBEBEBDFF929292FFBCBCBBFFF8F7F6FFF7F7F5FFF7F6F4FFF6F5F4FFF6F5149 F3FFF5F4F2FFF5F4F2FFF4F3F1FFF4F2F0FFF3F2F0FF91602DFF9C703DFFFAFA150 F9FFFAF9F9FFF9F9F8FFF9F8F7FFF8F8F7FFF8F7F6FFF7F7F5FFF7F6F5FFF6F5151 F4FFF6F5F3FFF5F4F3FFF5F4F2FFF4F3F1FFF4F3F0FF92612EFF9D723EFFFBFB152 FAFF9F9F9EFF7F7F7FFFAEAEADFFF9F8F7FFF8F8F7FFF8F7F6FFF7F7F5FFF7F6153 F5FFF6F6F4FFF6F5F3FFF5F4F3FFF5F4F2FFF4F3F1FF92622FFF9D7340FFFCFB154 FBFF818181FFC4C4C4FF8F8F8FFFFAF9F8FF7B7B7AFF797979FF757574FF7271155 71FF6D6D6DFF696969FF666665FF626261FFF5F4F2FF936430FF9E7441FFFCFC156 FCFFB5B5B5FF848484FFBEBDBDFFFAFAF9FFFAF9F8FFF9F9F7FFF9F8F7FFF8F8157 F6FFF8F7F5FFF7F6F5FFF7F6F4FFF6F5F3FFF6F5F3FF946531FF9F7542FFFDFD158 FCFFFCFCFCFFFCFCFBFFFBFBFAFFFBFAFAFFFAFAF9FFFAF9F8FFF9F9F8FFF9F8159 F7FFF8F8F6FFF8F7F6FFF7F6F5FFF7F6F4FFF6F5F4FF956633FFA07643FFFEFD160 FDFF8C8C8CFF525252FFA4A4A4FFFBFBFAFFFBFBFAFFFAFAF9FFFAF9F8FFF9F9161 F8FFF9F8F7FFF8F8F6FFF8F7F6FFF7F7F5FFF7F6F4FF966734FFA17844FFFEFE162 FEFF5F5F5FFF949494FF535353FFFCFCFBFF7B7B7BFF797979FF757575FF7272163 72FF6E6E6EFF6A6A69FF666666FF626262FFF7F7F5FF966935FFA17946FFFFFF164 FFFF878787FF5D5D5DFFA0A0A0FFFDFCFCFFFCFCFBFFFCFBFBFFFBFBFAFFFBFA165 F9FFFAFAF9FFFAF9F8FFF9F8F7FFF8F8F7FFF8F7F6FF976A36FFA27A47FFFFFF166 FFFFFFFFFFFFFEFEFEFFFEFEFEFFFDFDFDFFFDFDFCFFFCFCFBFFFCFBFBFFFBFB167 FAFFFBFAF9FFFAFAF9FFFAF9F8FFF9F9F7FFF9F8F7FF986B37FFA37B48FFBEA2168 7FFFBEA17EFFBDA17DFFBDA07CFFBD9F7CFFBC9F7BFFBB9E7AFFBB9D7AFFBB9D169 79FFBA9C78FFB99B78FFB99A77FFB89A76FFB89975FF996C39FFA37B48FFA37B170 48FFA27A47FFA27946FFA17845FFA07744FFA07643FF9F7542FF9E7441FF9E73171 40FF9D723FFF9C713EFF9C703DFF9B6F3CFF9A6E3BFF9A6D3AFF172 }173 102 end 174 103 object MenuItem3: TMenuItem 175 104 Action = ARemove 176 Bitmap.Data = {177 36040000424D3604000000000000360000002800000010000000100000000100178 2000000000000004000064000000640000000000000000000000000000000000179 0000000000000000000000000000000000000000000000000000000000000000180 0000000000000000000000000000000000000000000000000000000000000000181 0000000000000000000000000000000000000000000000000000000000000000182 0000000000000000000000000000000000003A3AE2FFC0C0C0FF000000000000183 000000000000000000003A3AE2FFC0C0C0FF0000000000000000000000000000184 0000000000000000000000000000000000000000000000000000000000000000185 0000000000003A3AE2FF3A3AE2FF3A3AE2FFC0C0C0FF00000000000000000000186 00000000000000000000000000003A3AE2FFC0C0C0FF00000000000000000000187 0000000000003A3AE2FF3A3AE2FF3A3AE2FFC0C0C0FF00000000000000000000188 000000000000000000003A3AE2FFC0C0C0FF0000000000000000000000000000189 000000000000000000003838E0FF3838E0FF3838E0FFC0C0C0FF000000000000190 0000000000003838E0FF3838E0FFC0C0C0FF0000000000000000000000000000191 00000000000000000000000000003535DDFF3535DDFF3535DDFFC0C0C0FF0000192 00003535DDFF3535DDFFC0C0C0FF000000000000000000000000000000000000193 0000000000000000000000000000000000003232DAFF3232DAFF3232DAFF3232194 DAFF3232DAFFC0C0C0FF00000000000000000000000000000000000000000000195 000000000000000000000000000000000000000000002F2FD7FF2F2FD7FF2F2F196 D7FFC0C0C0FF0000000000000000000000000000000000000000000000000000197 0000000000000000000000000000000000002C2CD4FF2C2CD4FF2C2CD4FF2C2C198 D4FF2C2CD4FFC0C0C0FF00000000000000000000000000000000000000000000199 00000000000000000000000000002929D1FF2929D1FF2929D1FFC0C0C0FF0000200 00002929D1FFC0C0C0FF00000000000000000000000000000000000000000000201 0000000000002626CEFF2626CEFF2626CEFF2626CEFFC0C0C0FF000000000000202 0000000000002626CEFF2626CEFFC0C0C0FF0000000000000000000000000000203 00002020C8FF2020C8FF2020C8FF2020C8FFC0C0C0FF00000000000000000000204 000000000000000000002020C8FF2020C8FFC0C0C0FF00000000000000000000205 00001818C0FF1818C0FFC0C0C0FF000000000000000000000000000000000000206 00000000000000000000000000001818C0FF1818C0FFC0C0C0FF000000000000207 0000000000000000000000000000000000000000000000000000000000000000208 0000000000000000000000000000000000000000000000000000000000000000209 0000000000000000000000000000000000000000000000000000000000000000210 0000000000000000000000000000000000000000000000000000211 }212 105 end 213 106 object MenuItem4: TMenuItem 214 107 Action = AMoveUp 215 Bitmap.Data = {216 36040000424D3604000000000000360000002800000010000000100000000100217 2000000000000004000064000000640000000000000000000000000000000000218 0000000000000000000000000000000000000000000000000000000000000000219 0000000000000000000000000000000000000000000000000000000000000000220 0000000000000000000000000000000000FF000000FF000000FF000000FF0000221 00FF000000FF000000FF00000000000000000000000000000000000000000000222 0000000000000000000000000000000000FFFF442CFFFF3C28FFFF3522FFFF2E223 1EFFFF2619FF000000FF00000000000000000000000000000000000000000000224 0000000000000000000000000000000000FFFF5337FFFF4C32FFFF442CFFFF3C225 28FFFF3623FF000000FF00000000000000000000000000000000000000000000226 0000000000000000000000000000000000FFFF6341FFFF5C3BFFFF5437FFFF4C227 32FFFF442CFF000000FF00000000000000000000000000000000000000000000228 0000000000000000000000000000000000FFFF724AFFFF6B46FFFF6441FFFF5D229 3CFFFF5437FF000000FF00000000000000000000000000000000000000000000230 0000000000000000000000000000000000FFFF8255FFFF7A4FFFFF744BFFFF6C231 46FFFF6441FF000000FF00000000000000000000000000000000000000000000232 0000000000000000000000000000000000FFFF915FFFFF8A5AFFFF8255FFFF7C233 51FFFF744CFF000000FF00000000000000000000000000000000000000000000234 00FF000000FF000000FF000000FF000000FFFFA169FFFF9A65FFFF9360FFFF8A235 5AFFFF8456FF000000FF000000FF000000FF000000FF000000FF000000000000236 0000000000FFFFC681FFFFBF7DFFFFB878FFFFB073FFFFAA6EFFFFA269FFFF9A237 65FFFF9360FFFF8C5BFFFF8456FFFF7C51FF000000FF00000000000000000000238 000000000000000000FFFFCF87FFFFC882FFFFC17DFFFFB878FFFFB174FFFFAA239 6EFFFFA269FFFF9A65FFFF9461FF000000FF0000000000000000000000000000240 00000000000000000000000000FFFFD78CFFFFD088FFFFC882FFFFC17DFFFFBA241 79FFFFB374FFFFAA6EFF000000FF000000000000000000000000000000000000242 0000000000000000000000000000000000FFFFE092FFFFD88CFFFFD088FFFFC8243 82FFFFC27EFF000000FF00000000000000000000000000000000000000000000244 000000000000000000000000000000000000000000FFFFE797FFFFE092FFFFD8245 8CFF000000FF0000000000000000000000000000000000000000000000000000246 00000000000000000000000000000000000000000000000000FFFFF09CFF0000247 00FF000000000000000000000000000000000000000000000000000000000000248 0000000000000000000000000000000000000000000000000000000000FF0000249 0000000000000000000000000000000000000000000000000000250 }251 108 end 252 109 object MenuItem5: TMenuItem 253 110 Action = AMoveDown 254 Bitmap.Data = {255 36040000424D3604000000000000360000002800000010000000100000000100256 2000000000000004000064000000640000000000000000000000000000000000257 00000000000000000000000000000000000000000000000000FF000000000000258 0000000000000000000000000000000000000000000000000000000000000000259 000000000000000000000000000000000000000000FFFFF09CFF000000FF0000260 0000000000000000000000000000000000000000000000000000000000000000261 0000000000000000000000000000000000FFFFD88CFFFFE092FFFFE797FF0000262 00FF000000000000000000000000000000000000000000000000000000000000263 00000000000000000000000000FFFFC27EFFFFC882FFFFD088FFFFD88CFFFFE0264 92FF000000FF0000000000000000000000000000000000000000000000000000265 000000000000000000FFFFAA6EFFFFB374FFFFBA79FFFFC17DFFFFC882FFFFD0266 88FFFFD78CFF000000FF00000000000000000000000000000000000000000000267 0000000000FFFF9461FFFF9A65FFFFA269FFFFAA6EFFFFB174FFFFB878FFFFC1268 7DFFFFC882FFFFCF87FF000000FF000000000000000000000000000000000000269 00FFFF7C51FFFF8456FFFF8C5BFFFF9360FFFF9A65FFFFA269FFFFAA6EFFFFB0270 73FFFFB878FFFFBF7DFFFFC681FF000000FF0000000000000000000000FF0000271 00FF000000FF000000FF000000FFFF8456FFFF8A5AFFFF9360FFFF9A65FFFFA1272 69FF000000FF000000FF000000FF000000FF000000FF00000000000000000000273 00000000000000000000000000FFFF744CFFFF7C51FFFF8255FFFF8A5AFFFF91274 5FFF000000FF0000000000000000000000000000000000000000000000000000275 00000000000000000000000000FFFF6441FFFF6C46FFFF744BFFFF7A4FFFFF82276 55FF000000FF0000000000000000000000000000000000000000000000000000277 00000000000000000000000000FFFF5437FFFF5D3CFFFF6441FFFF6B46FFFF72278 4AFF000000FF0000000000000000000000000000000000000000000000000000279 00000000000000000000000000FFFF442CFFFF4C32FFFF5437FFFF5C3BFFFF63280 41FF000000FF0000000000000000000000000000000000000000000000000000281 00000000000000000000000000FFFF3623FFFF3C28FFFF442CFFFF4C32FFFF53282 37FF000000FF0000000000000000000000000000000000000000000000000000283 00000000000000000000000000FFFF2619FFFF2E1EFFFF3522FFFF3C28FFFF44284 2CFF000000FF0000000000000000000000000000000000000000000000000000285 00000000000000000000000000FF000000FF000000FF000000FF000000FF0000286 00FF000000FF0000000000000000000000000000000000000000000000000000287 0000000000000000000000000000000000000000000000000000000000000000288 0000000000000000000000000000000000000000000000000000289 }290 111 end 291 112 end -
branches/generator/Forms/UFormRuleItems.pas
r128 r129 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 Menus, ActnList, StdCtrls, U Rules, UFormRuleItem;9 Menus, ActnList, StdCtrls, UGrammer, UFormRuleItem; 10 10 11 11 type -
branches/generator/Forms/UFormRules.lfm
r128 r129 7 7 ClientHeight = 611 8 8 ClientWidth = 857 9 DesignTimePPI = 120 9 10 OnClose = FormClose 10 11 OnCreate = FormCreate 11 12 OnShow = FormShow 12 LCLVersion = '1. 6.4.0'13 LCLVersion = '1.8.0.6' 13 14 object CoolBar1: TCoolBar 14 15 Left = 0 … … 76 77 item 77 78 Caption = 'Items' 78 Width = 50079 Width = 400 79 80 end 80 81 item 81 82 Caption = 'Char length' 82 83 Width = 80 84 end 85 item 86 Caption = 'Level' 87 Width = 70 83 88 end> 84 89 MultiSelect = True … … 126 131 object MenuItem1: TMenuItem 127 132 Action = AAdd 128 Bitmap.Data = {129 36040000424D3604000000000000360000002800000010000000100000000100130 2000000000000004000064000000640000000000000000000000000000000000131 0000000000000000000000000000000000000000000000000000000000000000132 0000000000000000000000000000000000000000000000000000000000000000133 000000000000000000000000000000000000D4D4D4FFB2B2B2FFB2B2B2FFD4D4134 D4FF000000000000000000000000000000000000000000000000000000000000135 0000000000000000000000000000709B70FF004A00FF004800FF4E764EFFB2B2136 B2FF000000000000000000000000000000000000000000000000000000000000137 0000000000000000000000000000004E00FF00C800FF00C400FF004800FFB2B2138 B2FF000000000000000000000000000000000000000000000000000000000000139 0000000000000000000000000000005000FF00CA00FF00C600FF004A00FFB2B2140 B2FF000000000000000000000000000000000000000000000000000000000000141 0000000000000000000000000000005300FF00CE00FF00CA00FF004C00FFB2B2142 B2FF00000000000000000000000000000000000000000000000000000000D4D4143 D4FFB2B2B2FFB2B2B2FFB2B2B2FF005400FF00D200FF00CE00FF004E00FFB2B2144 B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFD4D4D4FF0000000070A670FF005E145 00FF005C00FF005A00FF005800FF005600FF00D600FF00D000FF005000FF004E146 00FF004C00FF004A00FF004A00FF4E764EFFB2B2B2FF00000000006200FF8CFE147 8CFF00EA00FF00E600FF00E200FF00DE00FF00DA00FF00D400FF00D000FF00CC148 00FF00C800FF00C400FF00C200FF004800FFB2B2B2FF00000000006400FFECFF149 ECFF8CFE8CFF8CFE8CFF8CFE8CFF8CFE8CFF00DE00FF00D900FF00D400FF00D0150 00FF00CC00FF00C800FF00C400FF004A00FFD4D4D4FF0000000070A970FF0064151 00FF006400FF006200FF006000FF006000FF8CFE8CFF00DD00FF005800FF0056152 00FF005400FF005300FF005000FF709C70FF0000000000000000000000000000153 0000000000000000000000000000006000FF8CFE8CFF00E000FF005A00FFB2B2154 B2FF000000000000000000000000000000000000000000000000000000000000155 0000000000000000000000000000006200FF8CFE8CFF00E500FF005C00FFB2B2156 B2FF000000000000000000000000000000000000000000000000000000000000157 0000000000000000000000000000006400FF8CFE8CFF00E800FF005E00FFB2B2158 B2FF000000000000000000000000000000000000000000000000000000000000159 0000000000000000000000000000006400FFECFFECFF8CFE8CFF006000FFD4D4160 D4FF000000000000000000000000000000000000000000000000000000000000161 000000000000000000000000000070A970FF006400FF006200FF70A670FF0000162 0000000000000000000000000000000000000000000000000000163 }164 133 end 165 134 object MenuItem2: TMenuItem 166 135 Action = AModify 167 Bitmap.Data = {168 36040000424D3604000000000000360000002800000010000000100000000100169 2000000000000004000064000000640000000000000000000000986B37FF976A170 36FF966935FF966734FF956633FF946532FF946531FF936430FF92622FFF9261171 2EFF91602DFF90602CFF905F2BFF8F5D2AFF8E5C29FF8D5B28FF996C38FFF8F7172 F6FFF8F7F5FFF7F6F5FFF6F6F4FFF6F5F3FFF5F5F3FFF5F4F2FFF4F3F1FFF4F3173 F1FFF3F2F0FFF3F2EFFFF2F1EFFFF2F0EEFFF1F0EDFF8E5D29FF996D3AFFF9F8174 F7FF959594FF878787FF9B9A9AFFF7F6F4FFF6F5F3FFF6F5F3FFF5F4F2FFF4F3175 F1FFF4F3F1FFF3F2F0FFF3F2EFFFF2F1EFFFF2F1EEFF8F5E2AFF9A6E3BFFF9F9176 F8FF7C7C7CFFC4C4C4FF878787FFF7F6F5FF7A7A7AFF787878FF747474FF7171177 70FF6D6D6CFF696968FF656565FF616161FFF2F1EFFF905F2BFF9B6F3CFFFAF9178 F8FFBEBEBDFF929292FFBCBCBBFFF8F7F6FFF7F7F5FFF7F6F4FFF6F5F4FFF6F5179 F3FFF5F4F2FFF5F4F2FFF4F3F1FFF4F2F0FFF3F2F0FF91602DFF9C703DFFFAFA180 F9FFFAF9F9FFF9F9F8FFF9F8F7FFF8F8F7FFF8F7F6FFF7F7F5FFF7F6F5FFF6F5181 F4FFF6F5F3FFF5F4F3FFF5F4F2FFF4F3F1FFF4F3F0FF92612EFF9D723EFFFBFB182 FAFF9F9F9EFF7F7F7FFFAEAEADFFF9F8F7FFF8F8F7FFF8F7F6FFF7F7F5FFF7F6183 F5FFF6F6F4FFF6F5F3FFF5F4F3FFF5F4F2FFF4F3F1FF92622FFF9D7340FFFCFB184 FBFF818181FFC4C4C4FF8F8F8FFFFAF9F8FF7B7B7AFF797979FF757574FF7271185 71FF6D6D6DFF696969FF666665FF626261FFF5F4F2FF936430FF9E7441FFFCFC186 FCFFB5B5B5FF848484FFBEBDBDFFFAFAF9FFFAF9F8FFF9F9F7FFF9F8F7FFF8F8187 F6FFF8F7F5FFF7F6F5FFF7F6F4FFF6F5F3FFF6F5F3FF946531FF9F7542FFFDFD188 FCFFFCFCFCFFFCFCFBFFFBFBFAFFFBFAFAFFFAFAF9FFFAF9F8FFF9F9F8FFF9F8189 F7FFF8F8F6FFF8F7F6FFF7F6F5FFF7F6F4FFF6F5F4FF956633FFA07643FFFEFD190 FDFF8C8C8CFF525252FFA4A4A4FFFBFBFAFFFBFBFAFFFAFAF9FFFAF9F8FFF9F9191 F8FFF9F8F7FFF8F8F6FFF8F7F6FFF7F7F5FFF7F6F4FF966734FFA17844FFFEFE192 FEFF5F5F5FFF949494FF535353FFFCFCFBFF7B7B7BFF797979FF757575FF7272193 72FF6E6E6EFF6A6A69FF666666FF626262FFF7F7F5FF966935FFA17946FFFFFF194 FFFF878787FF5D5D5DFFA0A0A0FFFDFCFCFFFCFCFBFFFCFBFBFFFBFBFAFFFBFA195 F9FFFAFAF9FFFAF9F8FFF9F8F7FFF8F8F7FFF8F7F6FF976A36FFA27A47FFFFFF196 FFFFFFFFFFFFFEFEFEFFFEFEFEFFFDFDFDFFFDFDFCFFFCFCFBFFFCFBFBFFFBFB197 FAFFFBFAF9FFFAFAF9FFFAF9F8FFF9F9F7FFF9F8F7FF986B37FFA37B48FFBEA2198 7FFFBEA17EFFBDA17DFFBDA07CFFBD9F7CFFBC9F7BFFBB9E7AFFBB9D7AFFBB9D199 79FFBA9C78FFB99B78FFB99A77FFB89A76FFB89975FF996C39FFA37B48FFA37B200 48FFA27A47FFA27946FFA17845FFA07744FFA07643FF9F7542FF9E7441FF9E73201 40FF9D723FFF9C713EFF9C703DFF9B6F3CFF9A6E3BFF9A6D3AFF202 }203 136 end 204 137 object MenuItem3: TMenuItem 205 138 Action = ARemove 206 Bitmap.Data = {207 36040000424D3604000000000000360000002800000010000000100000000100208 2000000000000004000064000000640000000000000000000000000000000000209 0000000000000000000000000000000000000000000000000000000000000000210 0000000000000000000000000000000000000000000000000000000000000000211 0000000000000000000000000000000000000000000000000000000000000000212 0000000000000000000000000000000000003A3AE2FFC0C0C0FF000000000000213 000000000000000000003A3AE2FFC0C0C0FF0000000000000000000000000000214 0000000000000000000000000000000000000000000000000000000000000000215 0000000000003A3AE2FF3A3AE2FF3A3AE2FFC0C0C0FF00000000000000000000216 00000000000000000000000000003A3AE2FFC0C0C0FF00000000000000000000217 0000000000003A3AE2FF3A3AE2FF3A3AE2FFC0C0C0FF00000000000000000000218 000000000000000000003A3AE2FFC0C0C0FF0000000000000000000000000000219 000000000000000000003838E0FF3838E0FF3838E0FFC0C0C0FF000000000000220 0000000000003838E0FF3838E0FFC0C0C0FF0000000000000000000000000000221 00000000000000000000000000003535DDFF3535DDFF3535DDFFC0C0C0FF0000222 00003535DDFF3535DDFFC0C0C0FF000000000000000000000000000000000000223 0000000000000000000000000000000000003232DAFF3232DAFF3232DAFF3232224 DAFF3232DAFFC0C0C0FF00000000000000000000000000000000000000000000225 000000000000000000000000000000000000000000002F2FD7FF2F2FD7FF2F2F226 D7FFC0C0C0FF0000000000000000000000000000000000000000000000000000227 0000000000000000000000000000000000002C2CD4FF2C2CD4FF2C2CD4FF2C2C228 D4FF2C2CD4FFC0C0C0FF00000000000000000000000000000000000000000000229 00000000000000000000000000002929D1FF2929D1FF2929D1FFC0C0C0FF0000230 00002929D1FFC0C0C0FF00000000000000000000000000000000000000000000231 0000000000002626CEFF2626CEFF2626CEFF2626CEFFC0C0C0FF000000000000232 0000000000002626CEFF2626CEFFC0C0C0FF0000000000000000000000000000233 00002020C8FF2020C8FF2020C8FF2020C8FFC0C0C0FF00000000000000000000234 000000000000000000002020C8FF2020C8FFC0C0C0FF00000000000000000000235 00001818C0FF1818C0FFC0C0C0FF000000000000000000000000000000000000236 00000000000000000000000000001818C0FF1818C0FFC0C0C0FF000000000000237 0000000000000000000000000000000000000000000000000000000000000000238 0000000000000000000000000000000000000000000000000000000000000000239 0000000000000000000000000000000000000000000000000000000000000000240 0000000000000000000000000000000000000000000000000000241 }242 139 end 243 140 end -
branches/generator/Forms/UFormRules.pas
r128 r129 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, 9 ComCtrls, ActnList, Menus, U Rules, UListViewSort;9 ComCtrls, ActnList, Menus, UGrammer, UListViewSort; 10 10 11 11 type … … 147 147 Item.SubItems.Add(Items.GetString); 148 148 Item.SubItems.Add(IntToStr(Items.GetCharLength)); 149 Item.SubItems.Add(RuleLevelText[Level]); 149 150 end; 150 151 end; … … 175 176 1: Result := CompareString(BooleanText[TRule(Item1).CreateSourceNode], BooleanText[TRule(Item2).CreateSourceNode]); 176 177 2: Result := CompareString(TRule(Item1).GetString, TRule(Item2).GetString); 178 3: Result := CompareInteger(TRule(Item1).Items.GetCharLength, 179 TRule(Item2).Items.GetCharLength); 180 4: Result := CompareString(RuleLevelText[TRule(Item1).Level], 181 RuleLevelText[TRule(Item2).Level]); 177 182 end; 178 183 if ListViewSort1.Order = soDown then Result := -Result; -
branches/generator/Languages/generator.cs.po
r128 r129 12 12 "X-Generator: Poedit 1.8.8\n" 13 13 14 #: tformgrammer.buttoncancel.caption 15 msgctxt "tformgrammer.buttoncancel.caption" 16 msgid "Cancel" 17 msgstr "" 18 19 #: tformgrammer.buttonok.caption 20 msgid "OK" 21 msgstr "" 22 23 #: tformgrammer.caption 24 msgid "Grammer settings" 25 msgstr "" 26 27 #: tformgrammer.label1.caption 28 msgid "Start rule:" 29 msgstr "" 30 14 31 #: tformmain.abuildcompiler.caption 15 32 msgid "Build compiler" … … 84 101 msgstr "Soubor" 85 102 86 #: tformmain.menuitem6.caption87 msgid "-"88 msgstr "-"89 90 103 #: tformmain.menuitem8.caption 91 104 msgid "Tools" 92 105 msgstr "Nástroje" 106 107 #: tformrule.buttoncancel.caption 108 msgctxt "tformrule.buttoncancel.caption" 109 msgid "Cancel" 110 msgstr "" 111 112 #: tformrule.buttonok.caption 113 msgctxt "tformrule.buttonok.caption" 114 msgid "Ok" 115 msgstr "" 116 117 #: tformrule.caption 118 msgid "Rule" 119 msgstr "" 120 121 #: tformrule.checkboxcreatenode.caption 122 msgid "Create source node" 123 msgstr "" 124 125 #: tformrule.label1.caption 126 msgid "Name:" 127 msgstr "" 128 129 #: tformrule.label2.caption 130 msgid "Lavel:" 131 msgstr "" 132 133 #: tformrule.listview1.columns[0].caption 134 #, fuzzy 135 msgctxt "tformrule.listview1.columns[0].caption" 136 msgid "Name" 137 msgstr "Název" 138 139 #: tformrule.tabsheet1.caption 140 #, fuzzy 141 msgctxt "tformrule.tabsheet1.caption" 142 msgid "Items" 143 msgstr "PoloÅŸky" 144 145 #: tformrule.tabsheet2.caption 146 msgid "Links" 147 msgstr "" 148 149 #: tformrule.tabsheetusedby.caption 150 msgid "Used by" 151 msgstr "" 152 153 #: tformruleitem.buttoncancel.caption 154 msgctxt "tformruleitem.buttoncancel.caption" 155 msgid "Cancel" 156 msgstr "" 157 158 #: tformruleitem.buttonok.caption 159 msgctxt "tformruleitem.buttonok.caption" 160 msgid "Ok" 161 msgstr "" 162 163 #: tformruleitem.caption 164 msgid "Rule item" 165 msgstr "" 166 167 #: tformruleitem.checkboxanyexcept.caption 168 msgid "Any except" 169 msgstr "" 170 171 #: tformruleitem.checkboxoptional.caption 172 msgid "Optional" 173 msgstr "" 174 175 #: tformruleitem.checkboxrepetitive.caption 176 msgid "Repetitive" 177 msgstr "" 178 179 #: tformruleitem.label2.caption 180 msgid "Type:" 181 msgstr "" 182 183 #: tformruleitem.labelnonterminal.caption 184 msgid "Non-terminal:" 185 msgstr "" 186 187 #: tformruleitem.labelterminal.caption 188 msgid "Terminal:" 189 msgstr "" 190 191 #: tformruleitem.labelterminal1.caption 192 msgid "Terminal from:" 193 msgstr "" 194 195 #: tformruleitem.labelterminal2.caption 196 msgid "Terminal to:" 197 msgstr "" 198 199 #: tformruleitem.tabsheetnonterminal.caption 200 msgid "NonTerminal" 201 msgstr "" 202 203 #: tformruleitem.tabsheetsubitems.caption 204 msgid "SubItems" 205 msgstr "" 206 207 #: tformruleitem.tabsheetterminal.caption 208 msgid "Terminal" 209 msgstr "" 210 211 #: tformruleitem.tabsheetterminalrange.caption 212 msgid "TabSheetTerminalRange" 213 msgstr "" 93 214 94 215 #: tformruleitems.aadd.caption … … 173 294 174 295 #: tformrules.listview1.columns[2].caption 296 msgctxt "tformrules.listview1.columns[2].caption" 175 297 msgid "Items" 176 298 msgstr "PoloÅŸky" … … 180 302 msgstr "Znaková délka" 181 303 304 #: tformrules.listview1.columns[4].caption 305 msgid "Level" 306 msgstr "" 307 182 308 #: uformmain.sdoyouwanttosaveproject 183 309 msgid "There are unsaved changes in project. Do you want to save them?" -
branches/generator/Languages/generator.po
r128 r129 1 1 msgid "" 2 2 msgstr "Content-Type: text/plain; charset=UTF-8" 3 4 #: tformgrammer.buttoncancel.caption 5 msgctxt "tformgrammer.buttoncancel.caption" 6 msgid "Cancel" 7 msgstr "" 8 9 #: tformgrammer.buttonok.caption 10 msgid "OK" 11 msgstr "" 12 13 #: tformgrammer.caption 14 msgid "Grammer settings" 15 msgstr "" 16 17 #: tformgrammer.label1.caption 18 msgid "Start rule:" 19 msgstr "" 3 20 4 21 #: tformmain.abuildcompiler.caption … … 74 91 msgstr "" 75 92 76 #: tformmain.menuitem6.caption77 msgid "-"78 msgstr ""79 80 93 #: tformmain.menuitem8.caption 81 94 msgid "Tools" 95 msgstr "" 96 97 #: tformrule.buttoncancel.caption 98 msgctxt "tformrule.buttoncancel.caption" 99 msgid "Cancel" 100 msgstr "" 101 102 #: tformrule.buttonok.caption 103 msgctxt "tformrule.buttonok.caption" 104 msgid "Ok" 105 msgstr "" 106 107 #: tformrule.caption 108 msgid "Rule" 109 msgstr "" 110 111 #: tformrule.checkboxcreatenode.caption 112 msgid "Create source node" 113 msgstr "" 114 115 #: tformrule.label1.caption 116 msgid "Name:" 117 msgstr "" 118 119 #: tformrule.label2.caption 120 msgid "Lavel:" 121 msgstr "" 122 123 #: tformrule.listview1.columns[0].caption 124 msgctxt "tformrule.listview1.columns[0].caption" 125 msgid "Name" 126 msgstr "" 127 128 #: tformrule.tabsheet1.caption 129 msgctxt "tformrule.tabsheet1.caption" 130 msgid "Items" 131 msgstr "" 132 133 #: tformrule.tabsheet2.caption 134 msgid "Links" 135 msgstr "" 136 137 #: tformrule.tabsheetusedby.caption 138 msgid "Used by" 139 msgstr "" 140 141 #: tformruleitem.buttoncancel.caption 142 msgctxt "tformruleitem.buttoncancel.caption" 143 msgid "Cancel" 144 msgstr "" 145 146 #: tformruleitem.buttonok.caption 147 msgctxt "tformruleitem.buttonok.caption" 148 msgid "Ok" 149 msgstr "" 150 151 #: tformruleitem.caption 152 msgid "Rule item" 153 msgstr "" 154 155 #: tformruleitem.checkboxanyexcept.caption 156 msgid "Any except" 157 msgstr "" 158 159 #: tformruleitem.checkboxoptional.caption 160 msgid "Optional" 161 msgstr "" 162 163 #: tformruleitem.checkboxrepetitive.caption 164 msgid "Repetitive" 165 msgstr "" 166 167 #: tformruleitem.label2.caption 168 msgid "Type:" 169 msgstr "" 170 171 #: tformruleitem.labelnonterminal.caption 172 msgid "Non-terminal:" 173 msgstr "" 174 175 #: tformruleitem.labelterminal.caption 176 msgid "Terminal:" 177 msgstr "" 178 179 #: tformruleitem.labelterminal1.caption 180 msgid "Terminal from:" 181 msgstr "" 182 183 #: tformruleitem.labelterminal2.caption 184 msgid "Terminal to:" 185 msgstr "" 186 187 #: tformruleitem.tabsheetnonterminal.caption 188 msgid "NonTerminal" 189 msgstr "" 190 191 #: tformruleitem.tabsheetsubitems.caption 192 msgid "SubItems" 193 msgstr "" 194 195 #: tformruleitem.tabsheetterminal.caption 196 msgid "Terminal" 197 msgstr "" 198 199 #: tformruleitem.tabsheetterminalrange.caption 200 msgid "TabSheetTerminalRange" 82 201 msgstr "" 83 202 … … 163 282 164 283 #: tformrules.listview1.columns[2].caption 284 msgctxt "tformrules.listview1.columns[2].caption" 165 285 msgid "Items" 166 286 msgstr "" … … 170 290 msgstr "" 171 291 292 #: tformrules.listview1.columns[4].caption 293 msgid "Level" 294 msgstr "" 295 172 296 #: uformmain.sdoyouwanttosaveproject 173 297 msgid "There are unsaved changes in project. Do you want to save them?" -
branches/generator/UCore.lfm
r126 r129 3 3 OnDestroy = DataModuleDestroy 4 4 OldCreateOrder = False 5 Height = 586 6 HorizontalOffset = 393 7 VerticalOffset = 264 8 Width = 944 5 Height = 733 6 HorizontalOffset = 491 7 VerticalOffset = 297 8 Width = 1180 9 PPI = 120 9 10 object ImageList1: TImageList 10 left = 43211 top = 24311 left = 540 12 top = 304 12 13 Bitmap = { 13 14 4C690B0000001000000010000000000000000000000000000000000000000000 … … 369 370 MinVisiblePart = 50 370 371 EntireVisible = False 371 left = 273372 top = 1 23372 left = 341 373 top = 154 373 374 end 374 375 object XMLConfig1: TXMLConfig … … 376 377 RootName = 'CONFIG' 377 378 ReadOnly = False 378 left = 2 01379 top = 262379 left = 251 380 top = 328 380 381 end 381 382 end -
branches/generator/UCore.pas
r126 r129 6 6 7 7 uses 8 Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, U Rules, DOM,8 Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, UGrammer, DOM, 9 9 UPersistentForm; 10 10 -
branches/generator/UGrammer.pas
r128 r129 1 unit U Rules;1 unit UGrammer; 2 2 3 3 {$mode delphi}{$H+} … … 75 75 end; 76 76 77 TRuleLevel = (rlParser, rlTokenizer); 78 77 79 { TRule } 78 80 … … 84 86 Name: string; 85 87 CreateSourceNode: Boolean; 88 Level: TRuleLevel; 86 89 Items: TRuleItems; 87 90 Links: TRuleLinks; … … 110 113 private 111 114 FModified: Boolean; 112 function GetItemString(Item: TRuleItem; Required: Boolean): string;113 115 procedure SetModified(AValue: Boolean); 114 procedure BuildParser(FileName: string);115 procedure BuildMain(FileName: string);116 procedure BuildSource(FileName: string);117 116 public 118 117 FileName: string; … … 124 123 constructor Create; 125 124 destructor Destroy; override; 126 procedure BuildCompiler;127 125 procedure GetUsedByRule(RefRule: TRule; UsedByRules: TStrings); 128 126 function GetString: string; … … 130 128 end; 131 129 130 const 131 RuleLevelText: array[TRuleLevel] of string = ('Parser', 'Tokenizer'); 132 RuleTypeText: array[TRuleType] of string = ('and', 'or'); 133 134 132 135 implementation 133 136 134 const135 BooleanText: array[Boolean] of string = ('False', 'True');136 137 137 { TGrammer } 138 139 function TGrammer.GetItemString(Item: TRuleItem; Required: Boolean): string;140 begin141 Result := '';142 case Item.RuleItemType of143 ritTerminal: Result := 'Expect(''' +144 StringReplace(Item.Terminal, '''', '''''', [rfReplaceAll]) + ''', ' + BooleanText[Required] + ')';145 ritNonTerminal: Result := 'Parse' + Item.NonTerminal.Name + '(' + BooleanText[Required] + ')';146 ritTerminalRange: Result := 'ExpectRange(''' +147 StringReplace(Item.TerminalFrom, '''', '''''', [rfReplaceAll]) + ''', ''' +148 StringReplace(Item.TerminalTo, '''', '''''', [rfReplaceAll]) + ''', ' + BooleanText[Required] + ')';149 //ritSubItems: Line := 'Parse +';150 end;151 end;152 138 153 139 procedure TGrammer.SetModified(AValue: Boolean); … … 155 141 if FModified = AValue then Exit; 156 142 FModified := AValue; 157 end;158 159 procedure TGrammer.BuildParser(FileName: string);160 var161 ParserFile: TStringList;162 Rule: TRule;163 I: Integer;164 Line: string;165 Item: TRuleItem;166 Required: Boolean;167 begin168 ParserFile := TStringList.Create;169 with ParserFile do begin170 Add('unit Parser;');171 Add('');172 Add('{$MODE Delphi}');173 Add('');174 Add('interface');175 Add('');176 Add('uses');177 Add(' SysUtils;');178 Add('');179 Add('type');180 Add(' TParser = class');181 Add(' Content: string;');182 Add(' FileName: string;');183 Add(' Position: Integer;');184 Add(' procedure Error(Text: string);');185 Add(' function Expect(Text: string; Required: Boolean = False): Boolean;');186 Add(' function ExpectRange(CharFrom, CharTo: Char; Required: Boolean = False): Boolean;');187 for Rule in Rules do188 Add(' function Parse' + Rule.Name + '(Required: Boolean = False): Boolean;');189 Add(' constructor Create;');190 Add(' end;');191 Add('');192 Add('implementation');193 Add('');194 Add('constructor TParser.Create;');195 Add('begin');196 Add(' Position := 1;');197 Add('end;');198 Add('');199 Add('procedure TParser.Error(Text: string);');200 Add('begin');201 Add(' WriteLn(FileName + ''('' + IntToStr(Position) + '') Error: '' + Text);');202 Add('end;');203 Add('');204 Add('function TParser.Expect(Text: string; Required: Boolean = False): Boolean;');205 Add('var');206 Add(' ReadText: string;');207 Add(' StartPos: Integer;');208 Add('begin');209 Add(' StartPos := Position;');210 Add(' ReadText := Copy(Content, Position, Length(Text));');211 Add(' Inc(Position, Length(Text));');212 Add(' Result := Text = ReadText;');213 Add(' if not Result then begin');214 Add(' Position := StartPos;');215 Add(' if Required then Error(''Expected "'' + Text + ''" but found "'' + ReadText + ''".'');');216 Add(' end;');217 Add('end;');218 Add('');219 Add('function TParser.ExpectRange(CharFrom, CharTo: char; Required: Boolean = False): Boolean;');220 Add('var');221 Add(' ReadChar: Char;');222 Add(' StartPos: Integer;');223 Add('begin');224 Add(' StartPos := Position;');225 Add(' ReadChar := Content[Position];');226 Add(' Inc(Position, 1);');227 Add(' Result := (ReadChar >= CharFrom) and (ReadChar <= CharTo);');228 Add(' if not Result then begin');229 Add(' Position := StartPos;');230 Add(' if Required then Error(''Expected "'' + CharFrom + ''" to "'' + CharTo + ''" but found "'' + ReadChar + ''".'');');231 Add(' end;');232 Add('end;');233 Add('');234 for Rule in Rules do begin235 Add('function TParser.Parse' + Rule.Name + '(Required: Boolean = False): Boolean;');236 Add('begin');237 Add(' Result := True;');238 I := 0;239 for Item in Rule.Items do begin240 Required := not Item.Optional;241 Line := ' ';242 case Rule.Items.RuleType of243 rtOr: begin244 if I > 0 then Line := Line + 'else ';245 Line := Line + 'if ' + GetItemString(Item, False);246 Line := Line + ' then Exit';247 end;248 rtAnd: begin249 Line := Line + 'Result := Result and ';250 if Item.Optional then Line := Line + 'True;' + LineEnding;251 if Item.Repetitive then begin252 if not Item.Optional then253 Line := Line + ' ' + GetItemString(Item, Required) + ';' + LineEnding;254 Line := Line + ' repeat' + LineEnding + ' if not ';255 Required := False;256 end;257 Line := Line + GetItemString(Item, Required);258 if Item.Repetitive then Line := Line + ' then Break;' + LineEnding + ' until False';259 Line := Line + ';' + LineEnding + ' if not Result then Exit;';260 end;261 end;262 Add(Line);263 Inc(I);264 end;265 case Rule.Items.RuleType of266 rtOr: begin267 Add(' else begin');268 Add(' Error(''Unexpected token'');');269 Add(' Result := False;');270 Add(' end;');271 end;272 //rtAnd: Add(' if not Result then ShowError('''')');273 end;274 Add('end;');275 Add('');276 end;277 Add('');278 Add('end.');279 SaveToFile(FileName);280 end;281 FreeAndNil(ParserFile);282 end;283 284 procedure TGrammer.BuildMain(FileName: string);285 var286 ParserFile: TStringList;287 begin288 ParserFile := TStringList.Create;289 with ParserFile do begin290 Add('program Compiler;');291 Add('');292 Add('{$MODE Delphi}');293 Add('');294 Add('uses');295 Add(' Source, Parser, SysUtils;');296 Add('');297 Add('procedure Compile(FileName: string);');298 Add('var');299 Add(' SourceFile: file of Char;');300 Add(' Parser: TParser;');301 Add(' I: Integer;');302 Add('begin');303 Add(' AssignFile(SourceFile, FileName);');304 Add(' Reset(SourceFile);');305 Add(' Parser := TParser.Create;');306 Add(' Parser.FileName := ExtractFileName(FileName);');307 Add(' SetLength(Parser.Content, FileSize(SourceFile));');308 Add(' I := 1;');309 Add(' while not Eof(SourceFile) do begin');310 Add(' Read(SourceFile, Parser.Content[I]);');311 Add(' Inc(I);');312 Add(' end;');313 Add(' CloseFile(SourceFile);');314 if Assigned(TopRule) then315 Add(' Parser.Parse' + TopRule.Name + ';');316 Add(' Parser.Free;');317 Add('end;');318 Add('');319 Add('begin');320 Add(' if ParamCount > 0 then');321 Add(' Compile(ParamStr(1))');322 Add(' else WriteLn(''File name not specified as parameter.'');');323 Add('end.');324 SaveToFile(FileName);325 end;326 FreeAndNil(ParserFile);327 end;328 329 procedure TGrammer.BuildSource(FileName: string);330 var331 Rule: TRule;332 Item: TRuleItem;333 SourceFile: TStringList;334 TypeSectionStarted: Boolean;335 begin336 SourceFile := TStringList.Create;337 with SourceFile do begin338 Add('unit Source;');339 Add('');340 Add('{$MODE Delphi}');341 Add('');342 Add('interface');343 Add('');344 Add('uses');345 Add(' fgl;');346 Add('');347 TypeSectionStarted := False;348 for Rule in Rules do349 if Rule.CreateSourceNode then begin350 if not TypeSectionStarted then begin351 Add('type');352 TypeSectionStarted := True;353 end;354 Add(' T' + Rule.Name + ' = class;');355 end;356 Add('');357 for Rule in Rules do358 if Rule.CreateSourceNode then begin359 Add(' T' + Rule.Name + ' = class');360 for Item in Rule.Items do begin361 if Item.RuleItemType = ritNonTerminal then362 if Item.Repetitive then363 Add(' ' + Item.NonTerminal.Name + ': TFPGObjectList<T' + Item.NonTerminal.Name + '>;')364 else Add(' ' + Item.NonTerminal.Name + ': T' + Item.NonTerminal.Name + ';');365 end;366 Add(' end;' + LineEnding);367 end;368 Add('');369 Add('implementation');370 Add('');371 372 Add('end.');373 374 SaveToFile(FileName);375 end;376 FreeAndNil(SourceFile);377 143 end; 378 144 … … 449 215 FreeAndNil(Rules); 450 216 inherited Destroy; 451 end;452 453 procedure TGrammer.BuildCompiler;454 var455 OutputDir: string;456 begin457 OutputDir := 'Generated';458 ForceDirectories(OutputDir);459 460 BuildMain(OutputDir + DirectorySeparator + 'Compiler.pas');461 BuildSource(OutputDir + DirectorySeparator + 'Source.pas');462 BuildParser(OutputDir + DirectorySeparator + 'Parser.pas');463 217 end; 464 218 … … 666 420 WriteString(Node, 'Name', Name); 667 421 WriteBoolean(Node, 'CreateSourceNode', CreateSourceNode); 422 WriteInteger(Node, 'Level', Integer(Level)); 668 423 669 424 RuleItemsNode := Node.OwnerDocument.CreateElement('RuleItems'); … … 715 470 Name := ReadString(Node, 'Name', ''); 716 471 CreateSourceNode := ReadBoolean(Node, 'CreateSourceNode', False); 472 Level := TRuleLevel(ReadInteger(Node, 'Level', 0)); 717 473 718 474 ItemsNode := Node.FindNode('RuleItems'); -
branches/generator/generator.lpi
r127 r129 85 85 </Item4> 86 86 </RequiredPackages> 87 <Units Count=" 9">87 <Units Count="10"> 88 88 <Unit0> 89 89 <Filename Value="generator.lpr"/> … … 98 98 </Unit1> 99 99 <Unit2> 100 <Filename Value="U Rules.pas"/>100 <Filename Value="UGrammer.pas"/> 101 101 <IsPartOfProject Value="True"/> 102 102 </Unit2> … … 143 143 <ResourceBaseClass Value="Form"/> 144 144 </Unit8> 145 <Unit9> 146 <Filename Value="UBuilder.pas"/> 147 <IsPartOfProject Value="True"/> 148 </Unit9> 145 149 </Units> 146 150 </ProjectOptions> -
branches/generator/generator.lpr
r126 r129 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UCore, Common, TemplateGenerics, UFormMain, SysUtils 10 Forms, UCore, Common, TemplateGenerics, UFormMain, SysUtils, UBuilder 11 11 { you can add units after this }; 12 12 -
branches/generator/pascal.grm
r128 r129 5 5 <Name>BeginEnd</Name> 6 6 <CreateSourceNode>-1</CreateSourceNode> 7 <Level>0</Level> 7 8 <RuleItems> 8 9 <Type>0</Type> … … 33 34 <Name>IfThenElse</Name> 34 35 <CreateSourceNode>-1</CreateSourceNode> 36 <Level>0</Level> 35 37 <RuleItems> 36 38 <Type>0</Type> … … 91 93 <Name>WhileDo</Name> 92 94 <CreateSourceNode>-1</CreateSourceNode> 95 <Level>0</Level> 93 96 <RuleItems> 94 97 <Type>0</Type> … … 126 129 <Name>RepeatUntil</Name> 127 130 <CreateSourceNode>-1</CreateSourceNode> 131 <Level>0</Level> 128 132 <RuleItems> 129 133 <Type>0</Type> … … 161 165 <Name>ForToDo</Name> 162 166 <CreateSourceNode>-1</CreateSourceNode> 167 <Level>0</Level> 163 168 <RuleItems> 164 169 <Type>0</Type> … … 224 229 <Name>WithDo</Name> 225 230 <CreateSourceNode>-1</CreateSourceNode> 231 <Level>0</Level> 226 232 <RuleItems> 227 233 <Type>0</Type> … … 259 265 <Name>CaseOf</Name> 260 266 <CreateSourceNode>-1</CreateSourceNode> 267 <Level>0</Level> 261 268 <RuleItems> 262 269 <Type>0</Type> … … 331 338 <Name>Assignment</Name> 332 339 <CreateSourceNode>-1</CreateSourceNode> 340 <Level>0</Level> 333 341 <RuleItems> 334 342 <Type>0</Type> … … 359 367 <Name>Statement</Name> 360 368 <CreateSourceNode>-1</CreateSourceNode> 369 <Level>0</Level> 361 370 <RuleItems> 362 371 <Type>1</Type> … … 429 438 <Name>Expression</Name> 430 439 <CreateSourceNode>-1</CreateSourceNode> 440 <Level>0</Level> 431 441 <RuleItems> 432 442 <Type>0</Type> … … 443 453 <Name>VariableReference</Name> 444 454 <CreateSourceNode>0</CreateSourceNode> 455 <Level>0</Level> 445 456 <RuleItems> 446 457 <Type>0</Type> … … 457 468 <Name>Program</Name> 458 469 <CreateSourceNode>-1</CreateSourceNode> 470 <Level>0</Level> 459 471 <RuleItems> 460 472 <Type>0</Type> … … 515 527 <Name>Uses</Name> 516 528 <CreateSourceNode>0</CreateSourceNode> 529 <Level>0</Level> 517 530 <RuleItems> 518 531 <Type>0</Type> … … 566 579 <Name>UnitName</Name> 567 580 <CreateSourceNode>0</CreateSourceNode> 581 <Level>0</Level> 568 582 <RuleItems> 569 583 <Type>0</Type> … … 580 594 <Name>Function</Name> 581 595 <CreateSourceNode>-1</CreateSourceNode> 596 <Level>0</Level> 582 597 <RuleItems> 583 598 <Type>0</Type> … … 643 658 <Name>Identifier</Name> 644 659 <CreateSourceNode>0</CreateSourceNode> 660 <Level>1</Level> 645 661 <RuleItems> 646 662 <Type>0</Type> … … 687 703 <Name>VariableSection</Name> 688 704 <CreateSourceNode>0</CreateSourceNode> 705 <Level>0</Level> 689 706 <RuleItems> 690 707 <Type>0</Type> … … 708 725 <Name>FunctionParameters</Name> 709 726 <CreateSourceNode>0</CreateSourceNode> 727 <Level>0</Level> 710 728 <RuleItems> 711 729 <Type>0</Type> … … 759 777 <Name>FunctionParameter</Name> 760 778 <CreateSourceNode>0</CreateSourceNode> 779 <Level>0</Level> 761 780 <RuleItems> 762 781 <Type>0</Type> … … 787 806 <Name>VariableDefinition</Name> 788 807 <CreateSourceNode>0</CreateSourceNode> 808 <Level>0</Level> 789 809 <RuleItems> 790 810 <Type>0</Type> … … 822 842 <Name>TypeReference</Name> 823 843 <CreateSourceNode>0</CreateSourceNode> 844 <Level>0</Level> 824 845 <RuleItems> 825 846 <Type>0</Type> … … 836 857 <Name>VariableName</Name> 837 858 <CreateSourceNode>0</CreateSourceNode> 859 <Level>0</Level> 838 860 <RuleItems> 839 861 <Type>0</Type> … … 850 872 <Name>Unit</Name> 851 873 <CreateSourceNode>-1</CreateSourceNode> 874 <Level>0</Level> 852 875 <RuleItems> 853 876 <Type>0</Type> … … 920 943 <Name>UnitReference</Name> 921 944 <CreateSourceNode>0</CreateSourceNode> 945 <Level>0</Level> 922 946 <RuleItems> 923 947 <Type>0</Type> … … 934 958 <Name>ForInDo</Name> 935 959 <CreateSourceNode>-1</CreateSourceNode> 960 <Level>0</Level> 936 961 <RuleItems> 937 962 <Type>0</Type> … … 983 1008 <Name>TypeRecord</Name> 984 1009 <CreateSourceNode>-1</CreateSourceNode> 1010 <Level>0</Level> 985 1011 <RuleItems> 986 1012 <Type>0</Type> … … 1041 1067 <Name>ProgramName</Name> 1042 1068 <CreateSourceNode>0</CreateSourceNode> 1069 <Level>0</Level> 1043 1070 <RuleItems> 1044 1071 <Type>0</Type> … … 1055 1082 <Name>FunctionName</Name> 1056 1083 <CreateSourceNode>0</CreateSourceNode> 1084 <Level>0</Level> 1057 1085 <RuleItems> 1058 1086 <Type>0</Type> … … 1069 1097 <Name>Digit</Name> 1070 1098 <CreateSourceNode>0</CreateSourceNode> 1099 <Level>1</Level> 1071 1100 <RuleItems> 1072 1101 <Type>1</Type> … … 1084 1113 <Name>Sign</Name> 1085 1114 <CreateSourceNode>0</CreateSourceNode> 1115 <Level>1</Level> 1086 1116 <RuleItems> 1087 1117 <Type>1</Type> … … 1105 1135 <Name>UnsignedDigitSequence</Name> 1106 1136 <CreateSourceNode>0</CreateSourceNode> 1137 <Level>1</Level> 1107 1138 <RuleItems> 1108 1139 <Type>0</Type> … … 1126 1157 <Name>DigitSequence</Name> 1127 1158 <CreateSourceNode>0</CreateSourceNode> 1159 <Level>1</Level> 1128 1160 <RuleItems> 1129 1161 <Type>0</Type> … … 1147 1179 <Name>RealNumber</Name> 1148 1180 <CreateSourceNode>0</CreateSourceNode> 1181 <Level>1</Level> 1149 1182 <RuleItems> 1150 1183 <Type>0</Type> … … 1175 1208 <Name>IntegerNumber</Name> 1176 1209 <CreateSourceNode>0</CreateSourceNode> 1210 <Level>1</Level> 1177 1211 <RuleItems> 1178 1212 <Type>0</Type> … … 1189 1223 <Name>Number</Name> 1190 1224 <CreateSourceNode>0</CreateSourceNode> 1225 <Level>0</Level> 1191 1226 <RuleItems> 1192 1227 <Type>1</Type> … … 1210 1245 <Name>Letter</Name> 1211 1246 <CreateSourceNode>0</CreateSourceNode> 1247 <Level>1</Level> 1212 1248 <RuleItems> 1213 1249 <Type>1</Type> … … 1233 1269 <Name>ConstantSection</Name> 1234 1270 <CreateSourceNode>0</CreateSourceNode> 1271 <Level>0</Level> 1235 1272 <RuleItems> 1236 1273 <Type>0</Type> … … 1254 1291 <Name>Declaration</Name> 1255 1292 <CreateSourceNode>0</CreateSourceNode> 1293 <Level>0</Level> 1256 1294 <RuleItems> 1257 1295 <Type>1</Type> … … 1282 1320 <Name>TypeSection</Name> 1283 1321 <CreateSourceNode>0</CreateSourceNode> 1322 <Level>0</Level> 1284 1323 <RuleItems> 1285 1324 <Type>0</Type> … … 1303 1342 <Name>DeclarationBlock</Name> 1304 1343 <CreateSourceNode>0</CreateSourceNode> 1344 <Level>0</Level> 1305 1345 <RuleItems> 1306 1346 <Type>0</Type> … … 1324 1364 <Name>ConstantName</Name> 1325 1365 <CreateSourceNode>0</CreateSourceNode> 1366 <Level>0</Level> 1326 1367 <RuleItems> 1327 1368 <Type>0</Type> … … 1338 1379 <Name>Term</Name> 1339 1380 <CreateSourceNode>-1</CreateSourceNode> 1381 <Level>0</Level> 1340 1382 <RuleItems> 1341 1383 <Type>0</Type> … … 1375 1417 <Name>Factor</Name> 1376 1418 <CreateSourceNode>0</CreateSourceNode> 1419 <Level>0</Level> 1377 1420 <RuleItems> 1378 1421 <Type>1</Type> … … 1440 1483 <Name>Operator</Name> 1441 1484 <CreateSourceNode>0</CreateSourceNode> 1485 <Level>1</Level> 1442 1486 <RuleItems> 1443 1487 <Type>1</Type> … … 1587 1631 <Name>ConstantReference</Name> 1588 1632 <CreateSourceNode>0</CreateSourceNode> 1633 <Level>0</Level> 1589 1634 <RuleItems> 1590 1635 <Type>0</Type> … … 1601 1646 <Name>String</Name> 1602 1647 <CreateSourceNode>0</CreateSourceNode> 1648 <Level>1</Level> 1603 1649 <RuleItems> 1604 1650 <Type>0</Type> … … 1629 1675 <Name>StringCharacter</Name> 1630 1676 <CreateSourceNode>0</CreateSourceNode> 1677 <Level>1</Level> 1631 1678 <RuleItems> 1632 1679 <Type>1</Type> … … 1650 1697 <Name>ParameterName</Name> 1651 1698 <CreateSourceNode>0</CreateSourceNode> 1699 <Level>0</Level> 1652 1700 <RuleItems> 1653 1701 <Type>0</Type> … … 1664 1712 <Name>Comment1</Name> 1665 1713 <CreateSourceNode>0</CreateSourceNode> 1714 <Level>0</Level> 1666 1715 <RuleItems> 1667 1716 <Type>0</Type> … … 1692 1741 <Name>Comment2</Name> 1693 1742 <CreateSourceNode>0</CreateSourceNode> 1743 <Level>0</Level> 1694 1744 <RuleItems> 1695 1745 <Type>0</Type> … … 1720 1770 <Name>CommentLine</Name> 1721 1771 <CreateSourceNode>0</CreateSourceNode> 1772 <Level>0</Level> 1722 1773 <RuleItems> 1723 1774 <Type>0</Type> … … 1741 1792 <Name>CompilerDirective</Name> 1742 1793 <CreateSourceNode>0</CreateSourceNode> 1794 <Level>0</Level> 1743 1795 <RuleItems> 1744 1796 <Type>0</Type> … … 1769 1821 <Name>UnitInitialization</Name> 1770 1822 <CreateSourceNode>0</CreateSourceNode> 1823 <Level>0</Level> 1771 1824 <RuleItems> 1772 1825 <Type>0</Type> … … 1790 1843 <Name>UnitFinalization</Name> 1791 1844 <CreateSourceNode>0</CreateSourceNode> 1845 <Level>0</Level> 1792 1846 <RuleItems> 1793 1847 <Type>0</Type> … … 1811 1865 <Name>TypeDefinition</Name> 1812 1866 <CreateSourceNode>0</CreateSourceNode> 1867 <Level>0</Level> 1813 1868 <RuleItems> 1814 1869 <Type>0</Type> … … 1846 1901 <Name>ConstantDefinition</Name> 1847 1902 <CreateSourceNode>0</CreateSourceNode> 1903 <Level>0</Level> 1848 1904 <RuleItems> 1849 1905 <Type>0</Type> … … 1895 1951 <Name>Procedure</Name> 1896 1952 <CreateSourceNode>-1</CreateSourceNode> 1953 <Level>0</Level> 1897 1954 <RuleItems> 1898 1955 <Type>0</Type> … … 1944 2001 <Name>CaseOfState</Name> 1945 2002 <CreateSourceNode>0</CreateSourceNode> 2003 <Level>0</Level> 1946 2004 <RuleItems> 1947 2005 <Type>0</Type> … … 1979 2037 <Name>WhiteSpace</Name> 1980 2038 <CreateSourceNode>0</CreateSourceNode> 2039 <Level>1</Level> 1981 2040 <RuleItems> 1982 2041 <Type>1</Type> … … 2014 2073 <Name>WhiteSpaces</Name> 2015 2074 <CreateSourceNode>0</CreateSourceNode> 2075 <Level>1</Level> 2016 2076 <RuleItems> 2017 2077 <Type>0</Type> … … 2028 2088 <Name>Range</Name> 2029 2089 <CreateSourceNode>0</CreateSourceNode> 2090 <Level>0</Level> 2030 2091 <RuleItems> 2031 2092 <Type>0</Type> … … 2056 2117 <Name>TypeArray</Name> 2057 2118 <CreateSourceNode>0</CreateSourceNode> 2119 <Level>0</Level> 2058 2120 <RuleItems> 2059 2121 <Type>0</Type> … … 2121 2183 <Name>TypeSet</Name> 2122 2184 <CreateSourceNode>0</CreateSourceNode> 2185 <Level>0</Level> 2123 2186 <RuleItems> 2124 2187 <Type>0</Type> … … 2149 2212 <Name>TypeEnumeration</Name> 2150 2213 <CreateSourceNode>0</CreateSourceNode> 2214 <Level>0</Level> 2151 2215 <RuleItems> 2152 2216 <Type>0</Type> … … 2177 2241 <Name>IdentifierList</Name> 2178 2242 <CreateSourceNode>0</CreateSourceNode> 2243 <Level>0</Level> 2179 2244 <RuleItems> 2180 2245 <Type>0</Type> … … 2214 2279 <Name>Type</Name> 2215 2280 <CreateSourceNode>0</CreateSourceNode> 2281 <Level>0</Level> 2216 2282 <RuleItems> 2217 2283 <Type>1</Type> … … 2263 2329 <Name>TypePointer</Name> 2264 2330 <CreateSourceNode>0</CreateSourceNode> 2331 <Level>0</Level> 2265 2332 <RuleItems> 2266 2333 <Type>0</Type> … … 2278 2345 <AnyExcept>0</AnyExcept> 2279 2346 <NonTerminal>TypeReference</NonTerminal> 2347 </RuleItem> 2348 </RuleItems> 2349 </Rule> 2350 <Rule> 2351 <Name>HexNumber</Name> 2352 <CreateSourceNode>0</CreateSourceNode> 2353 <Level>1</Level> 2354 <RuleItems> 2355 <Type>0</Type> 2356 <RuleItem> 2357 <Type>0</Type> 2358 <Optional>0</Optional> 2359 <Repetitive>0</Repetitive> 2360 <AnyExcept>0</AnyExcept> 2361 <Terminal>$</Terminal> 2362 </RuleItem> 2363 <RuleItem> 2364 <Type>1</Type> 2365 <Optional>0</Optional> 2366 <Repetitive>0</Repetitive> 2367 <AnyExcept>0</AnyExcept> 2368 <NonTerminal>UnsignedDigitSequence</NonTerminal> 2280 2369 </RuleItem> 2281 2370 </RuleItems>
Note:
See TracChangeset
for help on using the changeset viewer.