Changeset 119
- Timestamp:
- Nov 29, 2017, 12:31:26 PM (7 years ago)
- Location:
- branches/generator
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormMain.lfm
r118 r119 1 1 object FormMain: TFormMain 2 Left = 3 822 Left = 376 3 3 Height = 678 4 Top = 1954 Top = 202 5 5 Width = 1050 6 6 Caption = 'Language generator' … … 17 17 Width = 1050 18 18 Align = alClient 19 ScrollBars = ssAutoBoth 19 20 TabOrder = 0 20 21 end … … 67 68 object MenuItem2: TMenuItem 68 69 Caption = 'File' 70 object MenuItem11: TMenuItem 71 Action = ANew 72 end 69 73 object MenuItem4: TMenuItem 70 74 Action = AOpen 75 end 76 object MenuItem10: TMenuItem 77 Action = ASave 71 78 end 72 79 object MenuItem5: TMenuItem … … 126 133 OnExecute = ABuildCompilerExecute 127 134 end 135 object ASave: TAction 136 Caption = 'Save' 137 ImageIndex = 5 138 OnExecute = ASaveExecute 139 end 140 object ANew: TAction 141 Caption = 'New' 142 ImageIndex = 10 143 OnExecute = ANewExecute 144 end 128 145 end 129 146 object OpenDialog1: TOpenDialog -
branches/generator/Forms/UFormMain.pas
r118 r119 15 15 TFormMain = class(TForm) 16 16 ABuildCompiler: TAction; 17 ANew: TAction; 18 ASave: TAction; 17 19 AExit: TAction; 18 20 AOpen: TAction; … … 24 26 MemoBNF: TMemo; 25 27 MenuItem1: TMenuItem; 28 MenuItem10: TMenuItem; 29 MenuItem11: TMenuItem; 26 30 MenuItem2: TMenuItem; 27 31 MenuItem3: TMenuItem; … … 39 43 procedure ABuildCompilerExecute(Sender: TObject); 40 44 procedure AExitExecute(Sender: TObject); 45 procedure ANewExecute(Sender: TObject); 41 46 procedure AOpenExecute(Sender: TObject); 42 47 procedure ARulesExecute(Sender: TObject); 43 48 procedure ASaveAsExecute(Sender: TObject); 49 procedure ASaveExecute(Sender: TObject); 44 50 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 45 51 procedure FormShow(Sender: TObject); 46 52 private 47 { private declarations }53 procedure ReloadMemo; 48 54 public 49 55 { public declarations } … … 70 76 FormRules.Rules := Core.Grammer.Rules; 71 77 FormRules.ShowModal; 72 MemoBNF.Lines.Text := Core.Grammer.GetBNF;78 ReloadMemo; 73 79 FreeAndNil(FormRules); 74 80 end; … … 82 88 end; 83 89 90 procedure TFormMain.ASaveExecute(Sender: TObject); 91 begin 92 Core.Grammer.SaveToXmlFile(Core.Grammer.FileName); 93 end; 94 84 95 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 85 96 begin … … 90 101 begin 91 102 Core.PersistentForm1.Load(Self, True); 92 MemoBNF.Lines.Text := Core.Grammer.GetBNF; 103 ReloadMemo; 104 end; 105 106 procedure TFormMain.ReloadMemo; 107 begin 108 MemoBNF.Lines.Text := Core.Grammer.GetString; 93 109 end; 94 110 … … 98 114 end; 99 115 116 procedure TFormMain.ANewExecute(Sender: TObject); 117 begin 118 Core.Grammer.Rules.Clear; 119 ReloadMemo; 120 end; 121 100 122 procedure TFormMain.ABuildCompilerExecute(Sender: TObject); 101 var102 ParserFile: TStringList;103 SourceFile: TStringList;104 Rule: TRule;105 Item: TRuleItem;106 OutputDir: string;107 Line: string;108 I: Integer;109 123 begin 110 OutputDir := 'Generated'; 111 ForceDirectories(OutputDir); 112 113 ParserFile := TStringList.Create; 114 with ParserFile do begin 115 Add('program Compiler;'); 116 Add(''); 117 Add('{$MODE Delphi}'); 118 Add(''); 119 Add('uses'); 120 Add(' Source;'); 121 Add(''); 122 Add('procedure Compile;'); 123 Add('begin'); 124 Add('end;'); 125 Add(''); 126 Add('begin'); 127 Add(' Compile;'); 128 Add('end.'); 129 SaveToFile(OutputDir + DirectorySeparator + 'Compiler.pas'); 130 end; 131 FreeAndNil(ParserFile); 132 133 SourceFile := TStringList.Create; 134 with SourceFile do begin 135 Add('unit Source;'); 136 Add(''); 137 Add('{$MODE Delphi}'); 138 Add(''); 139 Add('interface'); 140 Add(''); 141 Add('uses'); 142 Add(' fgl;'); 143 Add(''); 144 Add('type'); 145 for Rule in Core.Grammer.Rules do begin 146 Add(' T' + Rule.Name + ' = class;'); 147 end; 148 Add(''); 149 for Rule in Core.Grammer.Rules do begin 150 Add(' T' + Rule.Name + ' = class'); 151 for Item in Rule.Items do begin 152 if Item.RuleItemType = ritNonTerminal then 153 if Item.Repetitive then 154 Add(' ' + Item.NonTerminal.Name + ': TFPGObjectList<T' + Item.NonTerminal.Name + '>;') 155 else Add(' ' + Item.NonTerminal.Name + ': T' + Item.NonTerminal.Name + ';'); 156 end; 157 Add(' end;' + LineEnding); 158 end; 159 Add(''); 160 Add('implementation'); 161 Add(''); 162 for Rule in Core.Grammer.Rules do begin 163 Add('function Parse' + Rule.Name + ': Boolean;'); 164 Add('begin'); 165 I := 0; 166 for Item in Rule.Items do begin 167 Line := ' '; 168 if Rule.Items.RuleType = rtOr then begin 169 if I > 0 then Line := Line + 'else '; 170 Line := Line + 'if '; 171 end else 172 if Rule.Items.RuleType = rtAnd then begin 173 Line := Line + ''; 174 end; 175 if Item.RuleItemType = ritTerminal then 176 Line := Line + 'Expect(''' + Item.Terminal + ''')' 177 else if Item.RuleItemType = ritNonTerminal then 178 Line := Line + 'Parse' + Item.NonTerminal.Name; 179 if Rule.Items.RuleType = rtOr then begin 180 Line := Line + ' then '; 181 end else 182 if Rule.Items.RuleType = rtAnd then begin 183 Line := Line + ';'; 184 end; 185 Add(Line); 186 Inc(I); 187 end; 188 if Rule.Items.RuleType = rtOr then begin 189 Add(' else ShowError(''Unexpected token'');'); 190 end; 191 Add('end;'); 192 Add(''); 193 end; 194 195 Add('end.'); 196 197 SaveToFile(OutputDir + DirectorySeparator +'Source.pas'); 198 end; 199 FreeAndNil(SourceFile); 124 Core.Grammer.BuildCompiler; 200 125 end; 201 126 … … 205 130 if OpenDialog1.Execute then begin 206 131 Core.Grammer.LoadFromXmlFile(OpenDialog1.FileName); 132 ReloadMemo; 207 133 end; 208 134 end; -
branches/generator/Forms/UFormRule.lfm
r117 r119 15 15 Left = 376 16 16 Height = 25 17 Top = 4 7617 Top = 480 18 18 Width = 75 19 19 Anchors = [akLeft, akBottom] … … 25 25 Left = 168 26 26 Height = 25 27 Top = 4 7627 Top = 480 28 28 Width = 75 29 29 Anchors = [akLeft, akBottom] … … 41 41 end 42 42 object PageControl1: TPageControl 43 Left = 1644 Height = 42145 Top = 4843 Left = 8 44 Height = 392 45 Top = 80 46 46 Width = 640 47 47 ActivePage = TabSheet1 … … 63 63 TabOrder = 3 64 64 end 65 object CheckBoxCreateNode: TCheckBox 66 Left = 16 67 Height = 24 68 Top = 48 69 Width = 152 70 Caption = 'Create source node' 71 TabOrder = 4 72 end 65 73 end -
branches/generator/Forms/UFormRule.pas
r117 r119 16 16 ButtonOk: TButton; 17 17 ButtonCancel: TButton; 18 CheckBoxCreateNode: TCheckBox; 18 19 EditName: TEdit; 19 20 Label1: TLabel; … … 64 65 Self.Rule := Rule; 65 66 EditName.Text := Rule.Name; 67 CheckBoxCreateNode.Checked := Rule.CreateSourceNode; 66 68 FormRuleItems.LoadData(Rule.Items); 67 69 end; … … 70 72 begin 71 73 Rule.Name := EditName.Text; 74 Rule.CreateSourceNode := CheckBoxCreateNode.Checked; 72 75 FormRuleItems.SaveData(Rule.Items); 73 76 end; -
branches/generator/Forms/UFormRuleItems.pas
r117 r119 71 71 begin 72 72 if (Item.Index >= 0) and (Item.Index < RuleItems.Count) then begin 73 Item.Caption := RuleItems[Item.Index].Get BNF;73 Item.Caption := RuleItems[Item.Index].GetString; 74 74 Item.Data := RuleItems[Item.Index]; 75 75 end; … … 97 97 RuleItem: TRuleItem; 98 98 begin 99 RuleItem := TRuleItem(ListView.Selected.Data); 100 FormRuleItem := TFormRuleItem.Create(nil); 101 FormRuleItem.LoadData(RuleItem); 102 if FormRuleItem.ShowModal = mrOk then begin 103 FormRuleItem.SaveData(RuleItem); 104 ReloadList; 99 if Assigned(ListView.Selected) then begin 100 RuleItem := TRuleItem(ListView.Selected.Data); 101 FormRuleItem := TFormRuleItem.Create(nil); 102 FormRuleItem.LoadData(RuleItem); 103 if FormRuleItem.ShowModal = mrOk then begin 104 FormRuleItem.SaveData(RuleItem); 105 ReloadList; 106 end; 107 FreeAndNil(FormRuleItem); 105 108 end; 106 FreeAndNil(FormRuleItem);107 109 end; 108 110 -
branches/generator/Forms/UFormRules.lfm
r116 r119 72 72 end 73 73 item 74 Caption = 'Node' 75 Width = 80 76 end 77 item 74 78 Caption = 'Items' 75 Width = 62979 Width = 500 76 80 end> 77 81 MultiSelect = True -
branches/generator/Forms/UFormRules.pas
r117 r119 58 58 UFormRule, UCore; 59 59 60 const 61 BooleanText: array[Boolean] of string = ('No', 'Yes'); 62 60 63 { TFormRules } 61 64 … … 88 91 FormRule: TFormRule; 89 92 begin 90 Rule := TRule(ListView1.Selected.Data); 91 FormRule := TFormRule.Create(nil); 92 FormRule.LoadData(Rule); 93 if FormRule.ShowModal = mrOk then begin 94 FormRule.SaveData(Rule); 95 ReloadList; 93 if Assigned(ListView1.Selected) then begin 94 Rule := TRule(ListView1.Selected.Data); 95 FormRule := TFormRule.Create(nil); 96 FormRule.LoadData(Rule); 97 if FormRule.ShowModal = mrOk then begin 98 FormRule.SaveData(Rule); 99 ReloadList; 100 end; 101 FreeAndNil(FormRule); 96 102 end; 97 FreeAndNil(FormRule);98 103 end; 99 104 … … 123 128 Item.Caption := Rules[Item.Index].Name; 124 129 Item.Data := Rules[Item.Index]; 125 Item.SubItems.Add(Rules[Item.Index].Items.GetBNF); 130 Item.SubItems.Add(BooleanText[Rules[Item.Index].CreateSourceNode]); 131 Item.SubItems.Add(Rules[Item.Index].Items.GetString); 126 132 end; 127 133 end; -
branches/generator/UCore.lfm
r118 r119 11 11 top = 243 12 12 Bitmap = { 13 4C690 A000000100000001000000000000000000000000000000000000000000013 4C690B0000001000000010000000000000000000000000000000000000000000 14 14 000070A970FF006400FF006200FF70A670FF0000000000000000000000000000 15 15 0000000000000000000000000000000000000000000000000000000000000000 … … 331 331 38FF693534FF8B7070FFB2B2B2FF00000000D7D7D7FFB2B2B2FFB2B2B2FFB2B2 332 332 B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2B2FFB2B2 333 B2FFB2B2B2FFB2B2B2FFD7D7D7FF 333 B2FFB2B2B2FFB2B2B2FFD7D7D7FF0000000000000000F8CCA3FFEE9640FFEE96 334 40FFEE9640FFEE9640FFEE9640FFEE9640FFEE9640FFF8CEA8FF000000000000 335 00000000000000000000000000000000000000000000EE9640FFFFDCC8FFFFF2 336 EBFFFFFCFAFFFFFFFFFFFFFFFFFFFFFAF7FFF9AF68FFF8C799FFEDC49EFF0000 337 00000000000000000000000000000000000000000000EE9640FFFFEBDFFFFFDE 338 CBFFFFE0CEFFFFE2D1FFFFE3D3FFFFE5D5FFF9AF68FFFCEEE0FFFAD2ADFFEDC4 339 9EFF0000000000000000000000000000000000000000EE9640FFFFF5EFFFFFE1 340 CFFFFFE3D3FFFFE5D5FFFFE6D8FFFFE8DAFFF9AF68FFFEF6EFFFFCEFE2FFF9CB 341 A0FFEDC59FFF00000000000000000000000000000000EE9640FFFFFAF7FFFFE3 342 D3FFFFE5D7FFFFE7DAFFFFE9DDFFFFEBDFFFEBB27CFFF9AF68FFF9AF68FFF9AF 343 68FFF0A358FFEDEDEDFF000000000000000000000000EE9640FFFFFDFCFFFFE5 344 D6FFFFE7DAFFFFEADEFFFFECE1FFFFEEE4FFF1D9C7FFF2D9C8FFF2D9C8FFF2E2 345 D5FFF0AC6BFFD9D9D9FF000000000000000000000000EE9640FFFFFFFFFFFFE7 346 D9FFFFEADDFFFFECE1FFFFEEE5FFFFF1E8FFFFF2EAFFFFF3ECFFFFF3ECFFFFFD 347 FCFFF3B77BFFD9D9D9FF000000000000000000000000EE9640FFFFFFFFFFFFE8 348 DCFFFFEBE0FFFFEEE4FFFFF1EAFFFFF4EDFFFFF6F1FFFFF7F2FFFFF7F3FFFFFF 349 FFFFF4BE88FFD9D9D9FF000000000000000000000000EE9741FFFFFFFFFFFFEA 350 DEFFFFEEE4FFFFF1E9FFFFF5EFFFFFF7F3FFFFF9F6FFFFFAF7FFFFFAF7FFFFFF 351 FFFFF5C28FFFD9D9D9FF000000000000000000000000EE9843FFFFFEFDFFFFED 352 E2FFFFF1E8FFFFF4EDFFFFF7F2FFFFF9F6FFFFFCF9FFFFFDFCFFFFFDFBFFFFFF 353 FFFFF5C291FFD9D9D9FF000000000000000000000000EE9640FFFFFCFAFFFFEF 354 E6FFFFF2EBFFFFF5EFFFFFF8F4FFFFFBF8FFFFFDFBFFFFFFFFFFFFFDFDFFFFFF 355 FFFFF5C08DFFD9D9D9FF000000000000000000000000EE9640FFFFFAF7FFFFF1 356 E9FFFFF4EEFFFFF7F2FFFFF9F5FFFFFBF9FFFFFDFBFFFFFEFDFFFFFDFCFFFFFE 357 FEFFF4BB83FFD9D9D9FF000000000000000000000000EE9640FFFFF6F1FFFFF3 358 ECFFFFF5EFFFFFF7F3FFFFF9F6FFFFFBF9FFFFFCFBFFFFFDFBFFFFFDFCFFFFFD 359 FDFFF3B374FFD9D9D9FF000000000000000000000000EE9640FFFFF2EAFFFFF8 360 F4FFFFFCFAFFFFFDFCFFFFFEFDFFFFFEFEFFFFFEFEFFFFFEFDFFFFFEFDFFFFFD 361 FCFFF1A963FFD9D9D9FF000000000000000000000000F6C898FFEE9640FFEE96 362 40FFF09F51FFF1A860FFF2AE6CFFF3B274FFF3B476FFF3B273FFF2AE6BFFF1A7 363 5FFFE6BC93FFD9D9D9FF00000000000000000000000000000000EBEBEBFFD9D9 364 D9FFD9D9D9FFD9D9D9FFD9D9D9FFD9D9D9FFD9D9D9FFD9D9D9FFD9D9D9FFD9D9 365 D9FFD9D9D9FFEBEBEBFF00000000 334 366 } 335 367 end -
branches/generator/URules.pas
r117 r119 6 6 7 7 uses 8 Classes, SysUtils, fgl, DOM, XmlRead, XmlWrite, UXMLUtils ;8 Classes, SysUtils, fgl, DOM, XmlRead, XmlWrite, UXMLUtils, Math; 9 9 10 10 type … … 32 32 NonTerminal: TRule; 33 33 SubItems: TRuleItems; 34 function GetCharLength: Integer; 34 35 procedure LoadFromXmlNode(Node: TDOMNode); 35 36 procedure SaveToXmlNode(Node: TDOMNode); 36 function Get BNF: string;37 function GetString: string; 37 38 constructor Create; 38 39 destructor Destroy; override; … … 52 53 Grammer: TGrammer; 53 54 RuleType: TRuleType; 55 function GetCharLength: Integer; 54 56 procedure LoadFromXmlNode(Node: TDOMNode); 55 57 procedure SaveToXmlNode(Node: TDOMNode); 56 58 procedure UpdateRuleReference; 57 function Get BNF: string;59 function GetString: string; 58 60 property ParentRule: TRule read FParentRule write SetParentRule; 59 61 end; … … 78 80 public 79 81 Name: string; 82 CreateSourceNode: Boolean; 80 83 Items: TRuleItems; 81 84 Links: TRuleLinks; … … 85 88 procedure LoadFromXmlNode(Node: TDOMNode); 86 89 procedure SaveToXmlNode(Node: TDOMNode); 87 function Get BNF: string;90 function GetString: string; 88 91 end; 89 92 … … 95 98 procedure LoadFromXmlNode(Node: TDOMNode); 96 99 procedure SaveToXmlNode(Node: TDOMNode); 97 function Get BNF: string;100 function GetString: string; 98 101 end; 99 102 … … 101 104 102 105 TGrammer = class 106 private 107 FModified: Boolean; 108 procedure SetModified(AValue: Boolean); 109 procedure BuildMain(FileName: string); 110 procedure BuildSource(FileName: string); 111 public 103 112 FileName: string; 104 113 Rules: TRules; … … 107 116 constructor Create; 108 117 destructor Destroy; override; 109 function GetBNF: string; 118 procedure BuildCompiler; 119 function GetString: string; 120 property Modified: Boolean read FModified write SetModified; 110 121 end; 111 122 … … 113 124 114 125 { TGrammer } 126 127 procedure TGrammer.SetModified(AValue: Boolean); 128 begin 129 if FModified = AValue then Exit; 130 FModified := AValue; 131 end; 132 133 procedure TGrammer.BuildMain(FileName: string); 134 var 135 ParserFile: TStringList; 136 begin 137 ParserFile := TStringList.Create; 138 with ParserFile do begin 139 Add('program Compiler;'); 140 Add(''); 141 Add('{$MODE Delphi}'); 142 Add(''); 143 Add('uses'); 144 Add(' Source;'); 145 Add(''); 146 Add('procedure Compile;'); 147 Add('begin'); 148 Add('end;'); 149 Add(''); 150 Add('begin'); 151 Add(' Compile;'); 152 Add('end.'); 153 SaveToFile(FileName); 154 end; 155 FreeAndNil(ParserFile); 156 end; 157 158 procedure TGrammer.BuildSource(FileName: string); 159 var 160 Rule: TRule; 161 Item: TRuleItem; 162 Line: string; 163 I: Integer; 164 SourceFile: TStringList; 165 begin 166 SourceFile := TStringList.Create; 167 with SourceFile do begin 168 Add('unit Source;'); 169 Add(''); 170 Add('{$MODE Delphi}'); 171 Add(''); 172 Add('interface'); 173 Add(''); 174 Add('uses'); 175 Add(' fgl;'); 176 Add(''); 177 Add('type'); 178 for Rule in Rules do begin 179 Add(' T' + Rule.Name + ' = class;'); 180 end; 181 Add(''); 182 for Rule in Rules do begin 183 Add(' T' + Rule.Name + ' = class'); 184 for Item in Rule.Items do begin 185 if Item.RuleItemType = ritNonTerminal then 186 if Item.Repetitive then 187 Add(' ' + Item.NonTerminal.Name + ': TFPGObjectList<T' + Item.NonTerminal.Name + '>;') 188 else Add(' ' + Item.NonTerminal.Name + ': T' + Item.NonTerminal.Name + ';'); 189 end; 190 Add(' end;' + LineEnding); 191 end; 192 Add(''); 193 Add('implementation'); 194 Add(''); 195 for Rule in Rules do 196 if Rule.CreateSourceNode then begin 197 Add('function Parse' + Rule.Name + ': Boolean;'); 198 Add('begin'); 199 I := 0; 200 for Item in Rule.Items do begin 201 Line := ' '; 202 if Rule.Items.RuleType = rtOr then begin 203 if I > 0 then Line := Line + 'else '; 204 Line := Line + 'if '; 205 end else 206 if Rule.Items.RuleType = rtAnd then begin 207 Line := Line + ''; 208 end; 209 if Item.RuleItemType = ritTerminal then 210 Line := Line + 'Expect(''' + Item.Terminal + ''')' 211 else if Item.RuleItemType = ritNonTerminal then 212 Line := Line + 'Parse' + Item.NonTerminal.Name; 213 if Rule.Items.RuleType = rtOr then begin 214 Line := Line + ' then '; 215 end else 216 if Rule.Items.RuleType = rtAnd then begin 217 Line := Line + ';'; 218 end; 219 Add(Line); 220 Inc(I); 221 end; 222 if Rule.Items.RuleType = rtOr then begin 223 Add(' else ShowError(''Unexpected token'');'); 224 end; 225 Add('end;'); 226 Add(''); 227 end; 228 229 Add('end.'); 230 231 SaveToFile(FileName); 232 end; 233 FreeAndNil(SourceFile); 234 end; 115 235 116 236 procedure TGrammer.LoadFromXmlFile(FileName: string); … … 159 279 160 280 WriteXMLFile(Doc, FileName); 281 Modified := False; 161 282 finally 162 283 Doc.Free; … … 176 297 end; 177 298 178 function TGrammer.GetBNF: string; 179 begin 180 Result := Rules.GetBNF; 299 procedure TGrammer.BuildCompiler; 300 var 301 OutputDir: string; 302 begin 303 OutputDir := 'Generated'; 304 ForceDirectories(OutputDir); 305 306 BuildMain(OutputDir + DirectorySeparator + 'Compiler.pas'); 307 BuildSource(OutputDir + DirectorySeparator +'Source.pas'); 308 end; 309 310 function TGrammer.GetString: string; 311 begin 312 Result := Rules.GetString; 181 313 end; 182 314 … … 202 334 end; 203 335 204 function TRuleItem.Get BNF: string;336 function TRuleItem.GetString: string; 205 337 begin 206 338 case RuleItemType of 207 339 ritTerminal: Result := '"' + Terminal + '"'; 208 340 ritNonTerminal: Result := NonTerminal.Name; 209 ritSubItems: Result := '(' + SubItems.Get BNF+ ')';341 ritSubItems: Result := '(' + SubItems.GetString + ')'; 210 342 end; 211 343 if Optional then Result := '+' + Result; … … 230 362 FParentRule := AValue; 231 363 SubItems.ParentRule := AValue; 364 end; 365 366 function TRuleItem.GetCharLength: Integer; 367 begin 368 case RuleItemType of 369 ritTerminal: Result := Length(Terminal); 370 ritNonTerminal: Result := Length(NonTerminal.Name); 371 ritSubItems: Result := SubItems.GetCharLength; 372 end; 232 373 end; 233 374 … … 283 424 end; 284 425 285 function TRuleItems.Get BNF: string;426 function TRuleItems.GetString: string; 286 427 var 287 428 Item: TRuleItem; … … 293 434 else if RuleType = rtOr then Result := Result + ' | '; 294 435 end; 295 Result := Result + Item.Get BNF;436 Result := Result + Item.GetString; 296 437 end; 297 438 end; … … 301 442 if FParentRule = AValue then Exit; 302 443 FParentRule := AValue; 444 end; 445 446 function TRuleItems.GetCharLength: Integer; 447 var 448 Item: TRuleItem; 449 begin 450 Result := 0; 451 if RuleType = rtOr then begin 452 for Item in Self do 453 Result := Max(Result, Item.GetCharLength); 454 end else 455 if RuleType = rtAnd then begin 456 for Item in Self do 457 Result := Result + Item.GetCharLength; 458 end; 303 459 end; 304 460 … … 330 486 begin 331 487 WriteString(Node, 'Name', Name); 488 WriteBoolean(Node, 'CreateSourceNode', CreateSourceNode); 332 489 333 490 RuleItemsNode := Node.OwnerDocument.CreateElement('RuleItems'); … … 336 493 end; 337 494 338 function TRule.Get BNF: string;339 begin 340 Result := Name + ' ::= ' + Items.Get BNF;495 function TRule.GetString: string; 496 begin 497 Result := Name + ' ::= ' + Items.GetString; 341 498 end; 342 499 … … 370 527 begin 371 528 Name := ReadString(Node, 'Name', ''); 529 CreateSourceNode := ReadBoolean(Node, 'CreateSourceNode', False); 372 530 373 531 ItemsNode := Node.FindNode('RuleItems'); … … 418 576 end; 419 577 420 function TRules.Get BNF: string;578 function TRules.GetString: string; 421 579 var 422 580 Rule: TRule; … … 424 582 Result := ''; 425 583 for Rule in Self do begin 426 Result := Result + Rule.Get BNF+ LineEnding;584 Result := Result + Rule.GetString + LineEnding; 427 585 end; 428 586 end; -
branches/generator/pascal.grm
r118 r119 4 4 <Rule> 5 5 <Name>BeginEnd</Name> 6 <CreateSourceNode>-1</CreateSourceNode> 6 7 <RuleItems> 7 8 <Type>0</Type> … … 28 29 <Rule> 29 30 <Name>IfThenElse</Name> 31 <CreateSourceNode>-1</CreateSourceNode> 30 32 <RuleItems> 31 33 <Type>0</Type> … … 78 80 <Rule> 79 81 <Name>WhileDo</Name> 82 <CreateSourceNode>-1</CreateSourceNode> 80 83 <RuleItems> 81 84 <Type>0</Type> … … 108 111 <Rule> 109 112 <Name>RepeatUntil</Name> 113 <CreateSourceNode>-1</CreateSourceNode> 110 114 <RuleItems> 111 115 <Type>0</Type> … … 138 142 <Rule> 139 143 <Name>ForToDo</Name> 144 <CreateSourceNode>-1</CreateSourceNode> 140 145 <RuleItems> 141 146 <Type>0</Type> … … 150 155 <Optional>0</Optional> 151 156 <Repetitive>0</Repetitive> 152 <NonTerminal>VariableRef </NonTerminal>157 <NonTerminal>VariableReference</NonTerminal> 153 158 </RuleItem> 154 159 <RuleItem> … … 192 197 <Rule> 193 198 <Name>WithDo</Name> 199 <CreateSourceNode>-1</CreateSourceNode> 194 200 <RuleItems> 195 201 <Type>0</Type> … … 204 210 <Optional>0</Optional> 205 211 <Repetitive>0</Repetitive> 206 <NonTerminal>VariableRef </NonTerminal>212 <NonTerminal>VariableReference</NonTerminal> 207 213 </RuleItem> 208 214 <RuleItem> … … 222 228 <Rule> 223 229 <Name>CaseOf</Name> 230 <CreateSourceNode>-1</CreateSourceNode> 224 231 <RuleItems> 225 232 <Type>0</Type> … … 252 259 <Rule> 253 260 <Name>Assignment</Name> 254 <RuleItems> 255 <Type>0</Type> 256 <RuleItem> 257 <Type>1</Type> 258 <Optional>0</Optional> 259 <Repetitive>0</Repetitive> 260 <NonTerminal>VariableRef</NonTerminal> 261 <CreateSourceNode>-1</CreateSourceNode> 262 <RuleItems> 263 <Type>0</Type> 264 <RuleItem> 265 <Type>1</Type> 266 <Optional>0</Optional> 267 <Repetitive>0</Repetitive> 268 <NonTerminal>VariableReference</NonTerminal> 261 269 </RuleItem> 262 270 <RuleItem> … … 276 284 <Rule> 277 285 <Name>Statement</Name> 286 <CreateSourceNode>-1</CreateSourceNode> 278 287 <RuleItems> 279 288 <Type>1</Type> … … 330 339 <Rule> 331 340 <Name>Expression</Name> 332 <RuleItems> 333 <Type>0</Type> 334 </RuleItems> 335 </Rule> 336 <Rule> 337 <Name>VariableRef</Name> 338 <RuleItems> 339 <Type>0</Type> 341 <CreateSourceNode>-1</CreateSourceNode> 342 <RuleItems> 343 <Type>0</Type> 344 <RuleItem> 345 <Type>1</Type> 346 <Optional>0</Optional> 347 <Repetitive>0</Repetitive> 348 <NonTerminal>Term</NonTerminal> 349 </RuleItem> 350 </RuleItems> 351 </Rule> 352 <Rule> 353 <Name>VariableReference</Name> 354 <CreateSourceNode>0</CreateSourceNode> 355 <RuleItems> 356 <Type>0</Type> 357 <RuleItem> 358 <Type>1</Type> 359 <Optional>0</Optional> 360 <Repetitive>0</Repetitive> 361 <NonTerminal>Identifier</NonTerminal> 362 </RuleItem> 340 363 </RuleItems> 341 364 </Rule> 342 365 <Rule> 343 366 <Name>Program</Name> 367 <CreateSourceNode>-1</CreateSourceNode> 344 368 <RuleItems> 345 369 <Type>0</Type> … … 372 396 <RuleItem> 373 397 <Type>1</Type> 398 <Optional>-1</Optional> 399 <Repetitive>0</Repetitive> 400 <NonTerminal>Uses</NonTerminal> 401 </RuleItem> 402 <RuleItem> 403 <Type>1</Type> 404 <Optional>0</Optional> 405 <Repetitive>0</Repetitive> 406 <NonTerminal>DeclarationBlock</NonTerminal> 407 </RuleItem> 408 <RuleItem> 409 <Type>0</Type> 410 <Optional>0</Optional> 411 <Repetitive>0</Repetitive> 412 <Terminal>.</Terminal> 413 </RuleItem> 414 </RuleItems> 415 </Rule> 416 <Rule> 417 <Name>Uses</Name> 418 <CreateSourceNode>0</CreateSourceNode> 419 <RuleItems> 420 <Type>0</Type> 421 <RuleItem> 422 <Type>0</Type> 423 <Optional>0</Optional> 424 <Repetitive>0</Repetitive> 425 <Terminal>uses</Terminal> 426 </RuleItem> 427 <RuleItem> 428 <Type>1</Type> 429 <Optional>0</Optional> 430 <Repetitive>0</Repetitive> 431 <NonTerminal>UnitReference</NonTerminal> 432 </RuleItem> 433 <RuleItem> 434 <Type>0</Type> 435 <Optional>0</Optional> 436 <Repetitive>0</Repetitive> 437 <Terminal>,</Terminal> 438 </RuleItem> 439 </RuleItems> 440 </Rule> 441 <Rule> 442 <Name>UnitName</Name> 443 <CreateSourceNode>0</CreateSourceNode> 444 <RuleItems> 445 <Type>0</Type> 446 <RuleItem> 447 <Type>1</Type> 448 <Optional>0</Optional> 449 <Repetitive>0</Repetitive> 450 <NonTerminal>Identifier</NonTerminal> 451 </RuleItem> 452 </RuleItems> 453 </Rule> 454 <Rule> 455 <Name>Function</Name> 456 <CreateSourceNode>-1</CreateSourceNode> 457 <RuleItems> 458 <Type>0</Type> 459 <RuleItem> 460 <Type>0</Type> 461 <Optional>0</Optional> 462 <Repetitive>0</Repetitive> 463 <Terminal>function</Terminal> 464 </RuleItem> 465 <RuleItem> 466 <Type>1</Type> 467 <Optional>0</Optional> 468 <Repetitive>0</Repetitive> 469 <NonTerminal>FunctionName</NonTerminal> 470 </RuleItem> 471 <RuleItem> 472 <Type>1</Type> 473 <Optional>-1</Optional> 474 <Repetitive>0</Repetitive> 475 <NonTerminal>FunctionParameters</NonTerminal> 476 </RuleItem> 477 <RuleItem> 478 <Type>0</Type> 479 <Optional>0</Optional> 480 <Repetitive>0</Repetitive> 481 <Terminal>:</Terminal> 482 </RuleItem> 483 <RuleItem> 484 <Type>1</Type> 485 <Optional>0</Optional> 486 <Repetitive>0</Repetitive> 487 <NonTerminal>TypeReference</NonTerminal> 488 </RuleItem> 489 <RuleItem> 490 <Type>0</Type> 491 <Optional>0</Optional> 492 <Repetitive>0</Repetitive> 493 <Terminal>;</Terminal> 494 </RuleItem> 495 <RuleItem> 496 <Type>1</Type> 374 497 <Optional>0</Optional> 375 498 <Repetitive>0</Repetitive> … … 380 503 <Optional>0</Optional> 381 504 <Repetitive>0</Repetitive> 382 <Terminal>.</Terminal> 383 </RuleItem> 384 </RuleItems> 385 </Rule> 386 <Rule> 387 <Name>Uses</Name> 388 <RuleItems> 389 <Type>0</Type> 390 <RuleItem> 391 <Type>0</Type> 392 <Optional>0</Optional> 393 <Repetitive>0</Repetitive> 394 <Terminal>uses</Terminal> 395 </RuleItem> 396 <RuleItem> 397 <Type>1</Type> 398 <Optional>0</Optional> 399 <Repetitive>0</Repetitive> 400 <NonTerminal>UnitReference</NonTerminal> 401 </RuleItem> 402 <RuleItem> 403 <Type>0</Type> 404 <Optional>0</Optional> 405 <Repetitive>0</Repetitive> 406 <Terminal>,</Terminal> 407 </RuleItem> 408 </RuleItems> 409 </Rule> 410 <Rule> 411 <Name>UnitName</Name> 412 <RuleItems> 413 <Type>0</Type> 414 </RuleItems> 415 </Rule> 416 <Rule> 417 <Name>Function</Name> 418 <RuleItems> 419 <Type>0</Type> 420 <RuleItem> 421 <Type>0</Type> 422 <Optional>0</Optional> 423 <Repetitive>0</Repetitive> 424 <Terminal>function</Terminal> 425 </RuleItem> 426 <RuleItem> 427 <Type>1</Type> 428 <Optional>0</Optional> 429 <Repetitive>0</Repetitive> 430 <NonTerminal>FunctionName</NonTerminal> 431 </RuleItem> 432 <RuleItem> 433 <Type>1</Type> 505 <Terminal>;</Terminal> 506 </RuleItem> 507 </RuleItems> 508 </Rule> 509 <Rule> 510 <Name>Identifier</Name> 511 <CreateSourceNode>0</CreateSourceNode> 512 <RuleItems> 513 <Type>0</Type> 514 <RuleItem> 515 <Type>1</Type> 516 <Optional>0</Optional> 517 <Repetitive>0</Repetitive> 518 <NonTerminal>Letter</NonTerminal> 519 </RuleItem> 520 <RuleItem> 521 <Type>2</Type> 434 522 <Optional>-1</Optional> 435 <Repetitive>0</Repetitive> 436 <NonTerminal>FunctionParameters</NonTerminal> 437 </RuleItem> 438 <RuleItem> 439 <Type>0</Type> 440 <Optional>0</Optional> 441 <Repetitive>0</Repetitive> 442 <Terminal>:</Terminal> 443 </RuleItem> 444 <RuleItem> 445 <Type>1</Type> 446 <Optional>0</Optional> 447 <Repetitive>0</Repetitive> 448 <NonTerminal>TypeReference</NonTerminal> 449 </RuleItem> 450 <RuleItem> 451 <Type>0</Type> 452 <Optional>0</Optional> 453 <Repetitive>0</Repetitive> 454 <Terminal>;</Terminal> 455 </RuleItem> 456 <RuleItem> 457 <Type>1</Type> 458 <Optional>0</Optional> 459 <Repetitive>0</Repetitive> 460 <NonTerminal>BeginEnd</NonTerminal> 461 </RuleItem> 462 <RuleItem> 463 <Type>0</Type> 464 <Optional>0</Optional> 465 <Repetitive>0</Repetitive> 466 <Terminal>;</Terminal> 467 </RuleItem> 468 </RuleItems> 469 </Rule> 470 <Rule> 471 <Name>Identifier</Name> 472 <RuleItems> 473 <Type>0</Type> 523 <Repetitive>-1</Repetitive> 524 <SubItems> 525 <Type>1</Type> 526 <RuleItem> 527 <Type>1</Type> 528 <Optional>0</Optional> 529 <Repetitive>0</Repetitive> 530 <NonTerminal>Letter</NonTerminal> 531 </RuleItem> 532 <RuleItem> 533 <Type>1</Type> 534 <Optional>0</Optional> 535 <Repetitive>0</Repetitive> 536 <NonTerminal>Digit</NonTerminal> 537 </RuleItem> 538 <RuleItem> 539 <Type>0</Type> 540 <Optional>0</Optional> 541 <Repetitive>0</Repetitive> 542 <Terminal>_</Terminal> 543 </RuleItem> 544 </SubItems> 545 </RuleItem> 474 546 </RuleItems> 475 547 </Rule> 476 548 <Rule> 477 549 <Name>VarSection</Name> 550 <CreateSourceNode>0</CreateSourceNode> 478 551 <RuleItems> 479 552 <Type>0</Type> … … 494 567 <Rule> 495 568 <Name>FunctionParameters</Name> 569 <CreateSourceNode>0</CreateSourceNode> 496 570 <RuleItems> 497 571 <Type>0</Type> … … 518 592 <Optional>0</Optional> 519 593 <Repetitive>0</Repetitive> 520 <Terminal> ,</Terminal>594 <Terminal>;</Terminal> 521 595 </RuleItem> 522 596 <RuleItem> … … 538 612 <Rule> 539 613 <Name>FunctionParameter</Name> 540 <RuleItems> 541 <Type>0</Type> 614 <CreateSourceNode>0</CreateSourceNode> 615 <RuleItems> 616 <Type>0</Type> 617 <RuleItem> 618 <Type>1</Type> 619 <Optional>0</Optional> 620 <Repetitive>0</Repetitive> 621 <NonTerminal>ParameterName</NonTerminal> 622 </RuleItem> 623 <RuleItem> 624 <Type>0</Type> 625 <Optional>0</Optional> 626 <Repetitive>0</Repetitive> 627 <Terminal>:</Terminal> 628 </RuleItem> 629 <RuleItem> 630 <Type>1</Type> 631 <Optional>0</Optional> 632 <Repetitive>0</Repetitive> 633 <NonTerminal>TypeReference</NonTerminal> 634 </RuleItem> 542 635 </RuleItems> 543 636 </Rule> 544 637 <Rule> 545 638 <Name>VariableDefinition</Name> 639 <CreateSourceNode>0</CreateSourceNode> 546 640 <RuleItems> 547 641 <Type>0</Type> … … 574 668 <Rule> 575 669 <Name>TypeReference</Name> 576 <RuleItems> 577 <Type>0</Type> 670 <CreateSourceNode>0</CreateSourceNode> 671 <RuleItems> 672 <Type>0</Type> 673 <RuleItem> 674 <Type>1</Type> 675 <Optional>0</Optional> 676 <Repetitive>0</Repetitive> 677 <NonTerminal>Identifier</NonTerminal> 678 </RuleItem> 578 679 </RuleItems> 579 680 </Rule> 580 681 <Rule> 581 682 <Name>VariableName</Name> 582 <RuleItems> 583 <Type>0</Type> 683 <CreateSourceNode>0</CreateSourceNode> 684 <RuleItems> 685 <Type>0</Type> 686 <RuleItem> 687 <Type>1</Type> 688 <Optional>0</Optional> 689 <Repetitive>0</Repetitive> 690 <NonTerminal>Identifier</NonTerminal> 691 </RuleItem> 584 692 </RuleItems> 585 693 </Rule> 586 694 <Rule> 587 695 <Name>Unit</Name> 696 <CreateSourceNode>-1</CreateSourceNode> 588 697 <RuleItems> 589 698 <Type>0</Type> … … 606 715 <Terminal>;</Terminal> 607 716 </RuleItem> 717 <RuleItem> 718 <Type>1</Type> 719 <Optional>-1</Optional> 720 <Repetitive>0</Repetitive> 721 <NonTerminal>Uses</NonTerminal> 722 </RuleItem> 608 723 </RuleItems> 609 724 </Rule> 610 725 <Rule> 611 726 <Name>UnitReference</Name> 612 <RuleItems> 613 <Type>0</Type> 727 <CreateSourceNode>0</CreateSourceNode> 728 <RuleItems> 729 <Type>0</Type> 730 <RuleItem> 731 <Type>1</Type> 732 <Optional>0</Optional> 733 <Repetitive>0</Repetitive> 734 <NonTerminal>Identifier</NonTerminal> 735 </RuleItem> 614 736 </RuleItems> 615 737 </Rule> 616 738 <Rule> 617 739 <Name>ForInDo</Name> 740 <CreateSourceNode>-1</CreateSourceNode> 618 741 <RuleItems> 619 742 <Type>0</Type> … … 628 751 <Optional>0</Optional> 629 752 <Repetitive>0</Repetitive> 630 <NonTerminal>VariableRef </NonTerminal>753 <NonTerminal>VariableReference</NonTerminal> 631 754 </RuleItem> 632 755 <RuleItem> … … 658 781 <Rule> 659 782 <Name>TypeRecord</Name> 783 <CreateSourceNode>-1</CreateSourceNode> 660 784 <RuleItems> 661 785 <Type>0</Type> … … 708 832 <Rule> 709 833 <Name>ProgramName</Name> 710 <RuleItems> 711 <Type>0</Type> 834 <CreateSourceNode>0</CreateSourceNode> 835 <RuleItems> 836 <Type>0</Type> 837 <RuleItem> 838 <Type>1</Type> 839 <Optional>0</Optional> 840 <Repetitive>0</Repetitive> 841 <NonTerminal>Identifier</NonTerminal> 842 </RuleItem> 712 843 </RuleItems> 713 844 </Rule> 714 845 <Rule> 715 846 <Name>FunctionName</Name> 716 <RuleItems> 717 <Type>0</Type> 847 <CreateSourceNode>0</CreateSourceNode> 848 <RuleItems> 849 <Type>0</Type> 850 <RuleItem> 851 <Type>1</Type> 852 <Optional>0</Optional> 853 <Repetitive>0</Repetitive> 854 <NonTerminal>Identifier</NonTerminal> 855 </RuleItem> 856 </RuleItems> 857 </Rule> 858 <Rule> 859 <Name>Digit</Name> 860 <CreateSourceNode>0</CreateSourceNode> 861 <RuleItems> 862 <Type>1</Type> 863 <RuleItem> 864 <Type>0</Type> 865 <Optional>0</Optional> 866 <Repetitive>0</Repetitive> 867 <Terminal>0</Terminal> 868 </RuleItem> 869 <RuleItem> 870 <Type>0</Type> 871 <Optional>0</Optional> 872 <Repetitive>0</Repetitive> 873 <Terminal>1</Terminal> 874 </RuleItem> 875 <RuleItem> 876 <Type>0</Type> 877 <Optional>0</Optional> 878 <Repetitive>0</Repetitive> 879 <Terminal>2</Terminal> 880 </RuleItem> 881 <RuleItem> 882 <Type>0</Type> 883 <Optional>0</Optional> 884 <Repetitive>0</Repetitive> 885 <Terminal>3</Terminal> 886 </RuleItem> 887 <RuleItem> 888 <Type>0</Type> 889 <Optional>0</Optional> 890 <Repetitive>0</Repetitive> 891 <Terminal>4</Terminal> 892 </RuleItem> 893 <RuleItem> 894 <Type>0</Type> 895 <Optional>0</Optional> 896 <Repetitive>0</Repetitive> 897 <Terminal>5</Terminal> 898 </RuleItem> 899 <RuleItem> 900 <Type>0</Type> 901 <Optional>0</Optional> 902 <Repetitive>0</Repetitive> 903 <Terminal>6</Terminal> 904 </RuleItem> 905 <RuleItem> 906 <Type>0</Type> 907 <Optional>0</Optional> 908 <Repetitive>0</Repetitive> 909 <Terminal>7</Terminal> 910 </RuleItem> 911 <RuleItem> 912 <Type>0</Type> 913 <Optional>0</Optional> 914 <Repetitive>0</Repetitive> 915 <Terminal>8</Terminal> 916 </RuleItem> 917 <RuleItem> 918 <Type>0</Type> 919 <Optional>0</Optional> 920 <Repetitive>0</Repetitive> 921 <Terminal>9</Terminal> 922 </RuleItem> 923 </RuleItems> 924 </Rule> 925 <Rule> 926 <Name>Sign</Name> 927 <CreateSourceNode>0</CreateSourceNode> 928 <RuleItems> 929 <Type>1</Type> 930 <RuleItem> 931 <Type>0</Type> 932 <Optional>0</Optional> 933 <Repetitive>0</Repetitive> 934 <Terminal>+</Terminal> 935 </RuleItem> 936 <RuleItem> 937 <Type>0</Type> 938 <Optional>0</Optional> 939 <Repetitive>0</Repetitive> 940 <Terminal>-</Terminal> 941 </RuleItem> 942 </RuleItems> 943 </Rule> 944 <Rule> 945 <Name>UnsignedDigitSequence</Name> 946 <CreateSourceNode>0</CreateSourceNode> 947 <RuleItems> 948 <Type>0</Type> 949 <RuleItem> 950 <Type>1</Type> 951 <Optional>0</Optional> 952 <Repetitive>0</Repetitive> 953 <NonTerminal>Digit</NonTerminal> 954 </RuleItem> 955 <RuleItem> 956 <Type>1</Type> 957 <Optional>-1</Optional> 958 <Repetitive>-1</Repetitive> 959 <NonTerminal>Digit</NonTerminal> 960 </RuleItem> 961 </RuleItems> 962 </Rule> 963 <Rule> 964 <Name>DigitSequence</Name> 965 <CreateSourceNode>0</CreateSourceNode> 966 <RuleItems> 967 <Type>0</Type> 968 <RuleItem> 969 <Type>1</Type> 970 <Optional>-1</Optional> 971 <Repetitive>0</Repetitive> 972 <NonTerminal>Sign</NonTerminal> 973 </RuleItem> 974 <RuleItem> 975 <Type>1</Type> 976 <Optional>0</Optional> 977 <Repetitive>0</Repetitive> 978 <NonTerminal>UnsignedDigitSequence</NonTerminal> 979 </RuleItem> 980 </RuleItems> 981 </Rule> 982 <Rule> 983 <Name>RealNumber</Name> 984 <CreateSourceNode>0</CreateSourceNode> 985 <RuleItems> 986 <Type>0</Type> 987 <RuleItem> 988 <Type>1</Type> 989 <Optional>0</Optional> 990 <Repetitive>0</Repetitive> 991 <NonTerminal>DigitSequence</NonTerminal> 992 </RuleItem> 993 <RuleItem> 994 <Type>0</Type> 995 <Optional>0</Optional> 996 <Repetitive>0</Repetitive> 997 <Terminal>.</Terminal> 998 </RuleItem> 999 <RuleItem> 1000 <Type>1</Type> 1001 <Optional>0</Optional> 1002 <Repetitive>0</Repetitive> 1003 <NonTerminal>UnsignedDigitSequence</NonTerminal> 1004 </RuleItem> 1005 </RuleItems> 1006 </Rule> 1007 <Rule> 1008 <Name>IntegerNumber</Name> 1009 <CreateSourceNode>0</CreateSourceNode> 1010 <RuleItems> 1011 <Type>0</Type> 1012 <RuleItem> 1013 <Type>1</Type> 1014 <Optional>0</Optional> 1015 <Repetitive>0</Repetitive> 1016 <NonTerminal>DigitSequence</NonTerminal> 1017 </RuleItem> 1018 </RuleItems> 1019 </Rule> 1020 <Rule> 1021 <Name>Number</Name> 1022 <CreateSourceNode>0</CreateSourceNode> 1023 <RuleItems> 1024 <Type>1</Type> 1025 <RuleItem> 1026 <Type>1</Type> 1027 <Optional>0</Optional> 1028 <Repetitive>0</Repetitive> 1029 <NonTerminal>IntegerNumber</NonTerminal> 1030 </RuleItem> 1031 <RuleItem> 1032 <Type>1</Type> 1033 <Optional>0</Optional> 1034 <Repetitive>0</Repetitive> 1035 <NonTerminal>RealNumber</NonTerminal> 1036 </RuleItem> 1037 </RuleItems> 1038 </Rule> 1039 <Rule> 1040 <Name>Letter</Name> 1041 <CreateSourceNode>0</CreateSourceNode> 1042 <RuleItems> 1043 <Type>1</Type> 1044 <RuleItem> 1045 <Type>0</Type> 1046 <Optional>0</Optional> 1047 <Repetitive>0</Repetitive> 1048 <Terminal>a</Terminal> 1049 </RuleItem> 1050 <RuleItem> 1051 <Type>0</Type> 1052 <Optional>0</Optional> 1053 <Repetitive>0</Repetitive> 1054 <Terminal>b</Terminal> 1055 </RuleItem> 1056 <RuleItem> 1057 <Type>0</Type> 1058 <Optional>0</Optional> 1059 <Repetitive>0</Repetitive> 1060 <Terminal>c</Terminal> 1061 </RuleItem> 1062 <RuleItem> 1063 <Type>0</Type> 1064 <Optional>0</Optional> 1065 <Repetitive>0</Repetitive> 1066 <Terminal>d</Terminal> 1067 </RuleItem> 1068 <RuleItem> 1069 <Type>0</Type> 1070 <Optional>0</Optional> 1071 <Repetitive>0</Repetitive> 1072 <Terminal>e</Terminal> 1073 </RuleItem> 1074 <RuleItem> 1075 <Type>0</Type> 1076 <Optional>0</Optional> 1077 <Repetitive>0</Repetitive> 1078 <Terminal>f</Terminal> 1079 </RuleItem> 1080 <RuleItem> 1081 <Type>0</Type> 1082 <Optional>0</Optional> 1083 <Repetitive>0</Repetitive> 1084 <Terminal>g</Terminal> 1085 </RuleItem> 1086 <RuleItem> 1087 <Type>0</Type> 1088 <Optional>0</Optional> 1089 <Repetitive>0</Repetitive> 1090 <Terminal>h</Terminal> 1091 </RuleItem> 1092 <RuleItem> 1093 <Type>0</Type> 1094 <Optional>0</Optional> 1095 <Repetitive>0</Repetitive> 1096 <Terminal>i</Terminal> 1097 </RuleItem> 1098 <RuleItem> 1099 <Type>0</Type> 1100 <Optional>0</Optional> 1101 <Repetitive>0</Repetitive> 1102 <Terminal>j</Terminal> 1103 </RuleItem> 1104 <RuleItem> 1105 <Type>0</Type> 1106 <Optional>0</Optional> 1107 <Repetitive>0</Repetitive> 1108 <Terminal>k</Terminal> 1109 </RuleItem> 1110 <RuleItem> 1111 <Type>0</Type> 1112 <Optional>0</Optional> 1113 <Repetitive>0</Repetitive> 1114 <Terminal>l</Terminal> 1115 </RuleItem> 1116 <RuleItem> 1117 <Type>0</Type> 1118 <Optional>0</Optional> 1119 <Repetitive>0</Repetitive> 1120 <Terminal>m</Terminal> 1121 </RuleItem> 1122 <RuleItem> 1123 <Type>0</Type> 1124 <Optional>0</Optional> 1125 <Repetitive>0</Repetitive> 1126 <Terminal>n</Terminal> 1127 </RuleItem> 1128 <RuleItem> 1129 <Type>0</Type> 1130 <Optional>0</Optional> 1131 <Repetitive>0</Repetitive> 1132 <Terminal>o</Terminal> 1133 </RuleItem> 1134 <RuleItem> 1135 <Type>0</Type> 1136 <Optional>0</Optional> 1137 <Repetitive>0</Repetitive> 1138 <Terminal>p</Terminal> 1139 </RuleItem> 1140 <RuleItem> 1141 <Type>0</Type> 1142 <Optional>0</Optional> 1143 <Repetitive>0</Repetitive> 1144 <Terminal>q</Terminal> 1145 </RuleItem> 1146 <RuleItem> 1147 <Type>0</Type> 1148 <Optional>0</Optional> 1149 <Repetitive>0</Repetitive> 1150 <Terminal>r</Terminal> 1151 </RuleItem> 1152 <RuleItem> 1153 <Type>0</Type> 1154 <Optional>0</Optional> 1155 <Repetitive>0</Repetitive> 1156 <Terminal>s</Terminal> 1157 </RuleItem> 1158 <RuleItem> 1159 <Type>0</Type> 1160 <Optional>0</Optional> 1161 <Repetitive>0</Repetitive> 1162 <Terminal>t</Terminal> 1163 </RuleItem> 1164 <RuleItem> 1165 <Type>0</Type> 1166 <Optional>0</Optional> 1167 <Repetitive>0</Repetitive> 1168 <Terminal>u</Terminal> 1169 </RuleItem> 1170 <RuleItem> 1171 <Type>0</Type> 1172 <Optional>0</Optional> 1173 <Repetitive>0</Repetitive> 1174 <Terminal>v</Terminal> 1175 </RuleItem> 1176 <RuleItem> 1177 <Type>0</Type> 1178 <Optional>0</Optional> 1179 <Repetitive>0</Repetitive> 1180 <Terminal>w</Terminal> 1181 </RuleItem> 1182 <RuleItem> 1183 <Type>0</Type> 1184 <Optional>0</Optional> 1185 <Repetitive>0</Repetitive> 1186 <Terminal>x</Terminal> 1187 </RuleItem> 1188 <RuleItem> 1189 <Type>0</Type> 1190 <Optional>0</Optional> 1191 <Repetitive>0</Repetitive> 1192 <Terminal>y</Terminal> 1193 </RuleItem> 1194 <RuleItem> 1195 <Type>0</Type> 1196 <Optional>0</Optional> 1197 <Repetitive>0</Repetitive> 1198 <Terminal>z</Terminal> 1199 </RuleItem> 1200 </RuleItems> 1201 </Rule> 1202 <Rule> 1203 <Name>ConstSection</Name> 1204 <CreateSourceNode>0</CreateSourceNode> 1205 <RuleItems> 1206 <Type>0</Type> 1207 <RuleItem> 1208 <Type>0</Type> 1209 <Optional>0</Optional> 1210 <Repetitive>0</Repetitive> 1211 <Terminal>const</Terminal> 1212 </RuleItem> 1213 </RuleItems> 1214 </Rule> 1215 <Rule> 1216 <Name>Declaration</Name> 1217 <CreateSourceNode>0</CreateSourceNode> 1218 <RuleItems> 1219 <Type>1</Type> 1220 <RuleItem> 1221 <Type>1</Type> 1222 <Optional>0</Optional> 1223 <Repetitive>0</Repetitive> 1224 <NonTerminal>VarSection</NonTerminal> 1225 </RuleItem> 1226 <RuleItem> 1227 <Type>1</Type> 1228 <Optional>0</Optional> 1229 <Repetitive>0</Repetitive> 1230 <NonTerminal>ConstSection</NonTerminal> 1231 </RuleItem> 1232 <RuleItem> 1233 <Type>1</Type> 1234 <Optional>0</Optional> 1235 <Repetitive>0</Repetitive> 1236 <NonTerminal>TypeSection</NonTerminal> 1237 </RuleItem> 1238 </RuleItems> 1239 </Rule> 1240 <Rule> 1241 <Name>TypeSection</Name> 1242 <CreateSourceNode>0</CreateSourceNode> 1243 <RuleItems> 1244 <Type>0</Type> 1245 <RuleItem> 1246 <Type>0</Type> 1247 <Optional>0</Optional> 1248 <Repetitive>0</Repetitive> 1249 <Terminal>type</Terminal> 1250 </RuleItem> 1251 </RuleItems> 1252 </Rule> 1253 <Rule> 1254 <Name>DeclarationBlock</Name> 1255 <CreateSourceNode>0</CreateSourceNode> 1256 <RuleItems> 1257 <Type>0</Type> 1258 <RuleItem> 1259 <Type>1</Type> 1260 <Optional>-1</Optional> 1261 <Repetitive>-1</Repetitive> 1262 <NonTerminal>Declaration</NonTerminal> 1263 </RuleItem> 1264 <RuleItem> 1265 <Type>1</Type> 1266 <Optional>0</Optional> 1267 <Repetitive>0</Repetitive> 1268 <NonTerminal>BeginEnd</NonTerminal> 1269 </RuleItem> 1270 </RuleItems> 1271 </Rule> 1272 <Rule> 1273 <Name>ConstDefinition</Name> 1274 <CreateSourceNode>0</CreateSourceNode> 1275 <RuleItems> 1276 <Type>0</Type> 1277 <RuleItem> 1278 <Type>1</Type> 1279 <Optional>0</Optional> 1280 <Repetitive>0</Repetitive> 1281 <NonTerminal>ConstName</NonTerminal> 1282 </RuleItem> 1283 <RuleItem> 1284 <Type>0</Type> 1285 <Optional>0</Optional> 1286 <Repetitive>0</Repetitive> 1287 <Terminal>:</Terminal> 1288 </RuleItem> 1289 <RuleItem> 1290 <Type>1</Type> 1291 <Optional>0</Optional> 1292 <Repetitive>0</Repetitive> 1293 <NonTerminal>TypeReference</NonTerminal> 1294 </RuleItem> 1295 <RuleItem> 1296 <Type>0</Type> 1297 <Optional>0</Optional> 1298 <Repetitive>0</Repetitive> 1299 <Terminal>=</Terminal> 1300 </RuleItem> 1301 <RuleItem> 1302 <Type>0</Type> 1303 <Optional>0</Optional> 1304 <Repetitive>0</Repetitive> 1305 <Terminal>;</Terminal> 1306 </RuleItem> 1307 </RuleItems> 1308 </Rule> 1309 <Rule> 1310 <Name>ConstName</Name> 1311 <CreateSourceNode>0</CreateSourceNode> 1312 <RuleItems> 1313 <Type>0</Type> 1314 </RuleItems> 1315 </Rule> 1316 <Rule> 1317 <Name>Term</Name> 1318 <CreateSourceNode>0</CreateSourceNode> 1319 <RuleItems> 1320 <Type>0</Type> 1321 <RuleItem> 1322 <Type>1</Type> 1323 <Optional>0</Optional> 1324 <Repetitive>0</Repetitive> 1325 <NonTerminal>Factor</NonTerminal> 1326 </RuleItem> 1327 <RuleItem> 1328 <Type>2</Type> 1329 <Optional>-1</Optional> 1330 <Repetitive>-1</Repetitive> 1331 <SubItems> 1332 <Type>0</Type> 1333 <RuleItem> 1334 <Type>1</Type> 1335 <Optional>0</Optional> 1336 <Repetitive>0</Repetitive> 1337 <NonTerminal>Factor</NonTerminal> 1338 </RuleItem> 1339 <RuleItem> 1340 <Type>1</Type> 1341 <Optional>0</Optional> 1342 <Repetitive>0</Repetitive> 1343 <NonTerminal>Operator</NonTerminal> 1344 </RuleItem> 1345 </SubItems> 1346 </RuleItem> 1347 </RuleItems> 1348 </Rule> 1349 <Rule> 1350 <Name>Factor</Name> 1351 <CreateSourceNode>0</CreateSourceNode> 1352 <RuleItems> 1353 <Type>1</Type> 1354 <RuleItem> 1355 <Type>1</Type> 1356 <Optional>0</Optional> 1357 <Repetitive>0</Repetitive> 1358 <NonTerminal>VariableReference</NonTerminal> 1359 </RuleItem> 1360 <RuleItem> 1361 <Type>1</Type> 1362 <Optional>0</Optional> 1363 <Repetitive>0</Repetitive> 1364 <NonTerminal>ConstReference</NonTerminal> 1365 </RuleItem> 1366 <RuleItem> 1367 <Type>2</Type> 1368 <Optional>0</Optional> 1369 <Repetitive>0</Repetitive> 1370 <SubItems> 1371 <Type>0</Type> 1372 <RuleItem> 1373 <Type>0</Type> 1374 <Optional>0</Optional> 1375 <Repetitive>0</Repetitive> 1376 <Terminal>(</Terminal> 1377 </RuleItem> 1378 <RuleItem> 1379 <Type>1</Type> 1380 <Optional>0</Optional> 1381 <Repetitive>0</Repetitive> 1382 <NonTerminal>Expression</NonTerminal> 1383 </RuleItem> 1384 <RuleItem> 1385 <Type>0</Type> 1386 <Optional>0</Optional> 1387 <Repetitive>0</Repetitive> 1388 <Terminal>)</Terminal> 1389 </RuleItem> 1390 </SubItems> 1391 </RuleItem> 1392 <RuleItem> 1393 <Type>1</Type> 1394 <Optional>0</Optional> 1395 <Repetitive>0</Repetitive> 1396 <NonTerminal>Number</NonTerminal> 1397 </RuleItem> 1398 <RuleItem> 1399 <Type>1</Type> 1400 <Optional>0</Optional> 1401 <Repetitive>0</Repetitive> 1402 <NonTerminal>String</NonTerminal> 1403 </RuleItem> 1404 </RuleItems> 1405 </Rule> 1406 <Rule> 1407 <Name>Operator</Name> 1408 <CreateSourceNode>0</CreateSourceNode> 1409 <RuleItems> 1410 <Type>1</Type> 1411 <RuleItem> 1412 <Type>0</Type> 1413 <Optional>0</Optional> 1414 <Repetitive>0</Repetitive> 1415 <Terminal><</Terminal> 1416 </RuleItem> 1417 <RuleItem> 1418 <Type>0</Type> 1419 <Optional>0</Optional> 1420 <Repetitive>0</Repetitive> 1421 <Terminal>></Terminal> 1422 </RuleItem> 1423 <RuleItem> 1424 <Type>0</Type> 1425 <Optional>0</Optional> 1426 <Repetitive>0</Repetitive> 1427 <Terminal><=</Terminal> 1428 </RuleItem> 1429 <RuleItem> 1430 <Type>0</Type> 1431 <Optional>0</Optional> 1432 <Repetitive>0</Repetitive> 1433 <Terminal>>=</Terminal> 1434 </RuleItem> 1435 <RuleItem> 1436 <Type>0</Type> 1437 <Optional>0</Optional> 1438 <Repetitive>0</Repetitive> 1439 <Terminal>=</Terminal> 1440 </RuleItem> 1441 <RuleItem> 1442 <Type>0</Type> 1443 <Optional>0</Optional> 1444 <Repetitive>0</Repetitive> 1445 <Terminal><></Terminal> 1446 </RuleItem> 1447 <RuleItem> 1448 <Type>0</Type> 1449 <Optional>0</Optional> 1450 <Repetitive>0</Repetitive> 1451 <Terminal>+</Terminal> 1452 </RuleItem> 1453 <RuleItem> 1454 <Type>0</Type> 1455 <Optional>0</Optional> 1456 <Repetitive>0</Repetitive> 1457 <Terminal>-</Terminal> 1458 </RuleItem> 1459 <RuleItem> 1460 <Type>0</Type> 1461 <Optional>0</Optional> 1462 <Repetitive>0</Repetitive> 1463 <Terminal>/</Terminal> 1464 </RuleItem> 1465 <RuleItem> 1466 <Type>0</Type> 1467 <Optional>0</Optional> 1468 <Repetitive>0</Repetitive> 1469 <Terminal>*</Terminal> 1470 </RuleItem> 1471 <RuleItem> 1472 <Type>0</Type> 1473 <Optional>0</Optional> 1474 <Repetitive>0</Repetitive> 1475 <Terminal>div</Terminal> 1476 </RuleItem> 1477 <RuleItem> 1478 <Type>0</Type> 1479 <Optional>0</Optional> 1480 <Repetitive>0</Repetitive> 1481 <Terminal>+</Terminal> 1482 </RuleItem> 1483 <RuleItem> 1484 <Type>0</Type> 1485 <Optional>0</Optional> 1486 <Repetitive>0</Repetitive> 1487 <Terminal>-</Terminal> 1488 </RuleItem> 1489 </RuleItems> 1490 </Rule> 1491 <Rule> 1492 <Name>ConstReference</Name> 1493 <CreateSourceNode>0</CreateSourceNode> 1494 <RuleItems> 1495 <Type>0</Type> 1496 <RuleItem> 1497 <Type>1</Type> 1498 <Optional>0</Optional> 1499 <Repetitive>0</Repetitive> 1500 <NonTerminal>Identifier</NonTerminal> 1501 </RuleItem> 1502 </RuleItems> 1503 </Rule> 1504 <Rule> 1505 <Name>String</Name> 1506 <CreateSourceNode>0</CreateSourceNode> 1507 <RuleItems> 1508 <Type>0</Type> 1509 <RuleItem> 1510 <Type>0</Type> 1511 <Optional>0</Optional> 1512 <Repetitive>0</Repetitive> 1513 <Terminal>'</Terminal> 1514 </RuleItem> 1515 <RuleItem> 1516 <Type>1</Type> 1517 <Optional>-1</Optional> 1518 <Repetitive>-1</Repetitive> 1519 <NonTerminal>StringCharacter</NonTerminal> 1520 </RuleItem> 1521 <RuleItem> 1522 <Type>0</Type> 1523 <Optional>0</Optional> 1524 <Repetitive>0</Repetitive> 1525 <Terminal>'</Terminal> 1526 </RuleItem> 1527 </RuleItems> 1528 </Rule> 1529 <Rule> 1530 <Name>StringCharacter</Name> 1531 <CreateSourceNode>0</CreateSourceNode> 1532 <RuleItems> 1533 <Type>0</Type> 1534 </RuleItems> 1535 </Rule> 1536 <Rule> 1537 <Name>ParameterName</Name> 1538 <CreateSourceNode>0</CreateSourceNode> 1539 <RuleItems> 1540 <Type>0</Type> 1541 <RuleItem> 1542 <Type>1</Type> 1543 <Optional>0</Optional> 1544 <Repetitive>0</Repetitive> 1545 <NonTerminal>Identifier</NonTerminal> 1546 </RuleItem> 718 1547 </RuleItems> 719 1548 </Rule>
Note:
See TracChangeset
for help on using the changeset viewer.