Changeset 111 for branches/generator
- Timestamp:
- Aug 9, 2017, 12:09:47 AM (7 years ago)
- Location:
- branches/generator
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormMain.pas
r110 r111 56 56 procedure TFormMain.ARulesExecute(Sender: TObject); 57 57 begin 58 FormRules.Rules := Core. Rules;58 FormRules.Rules := Core.Grammer.Rules; 59 59 FormRules.ShowModal; 60 MemoBNF.Lines.Text := Core. Rules.GetBNF;60 MemoBNF.Lines.Text := Core.Grammer.GetBNF; 61 61 end; 62 62 63 63 procedure TFormMain.ASaveAsExecute(Sender: TObject); 64 64 begin 65 SaveDialog1.FileName := Core. Rules.FileName;65 SaveDialog1.FileName := Core.Grammer.FileName; 66 66 if SaveDialog1.Execute then begin 67 Core. Rules.SaveToXmlFile(SaveDialog1.FileName);67 Core.Grammer.SaveToXmlFile(SaveDialog1.FileName); 68 68 end; 69 69 end; … … 71 71 procedure TFormMain.FormShow(Sender: TObject); 72 72 begin 73 MemoBNF.Lines.Text := Core. Rules.GetBNF;73 MemoBNF.Lines.Text := Core.Grammer.GetBNF; 74 74 end; 75 75 … … 81 81 procedure TFormMain.AOpenExecute(Sender: TObject); 82 82 begin 83 OpenDialog1.FileName := Core. Rules.FileName;83 OpenDialog1.FileName := Core.Grammer.FileName; 84 84 if OpenDialog1.Execute then begin 85 Core. Rules.LoadFromXmlFile(OpenDialog1.FileName);85 Core.Grammer.LoadFromXmlFile(OpenDialog1.FileName); 86 86 end; 87 87 end; -
branches/generator/Forms/UFormRule.lfm
r110 r111 47 47 object ListView: TListView 48 48 Left = 16 49 Height = 2 6450 Top = 8049 Height = 232 50 Top = 112 51 51 Width = 624 52 52 Anchors = [akTop, akLeft, akBottom] … … 67 67 OnKeyPress = ListViewKeyPress 68 68 OnSelectItem = ListViewSelectItem 69 end 70 object Label2: TLabel 71 Left = 24 72 Height = 24 73 Top = 64 74 Width = 82 75 Caption = 'Operator:' 76 ParentColor = False 77 end 78 object ComboBox1: TComboBox 79 Left = 186 80 Height = 36 81 Top = 61 82 Width = 390 83 ItemHeight = 0 84 Items.Strings = ( 85 'And' 86 'Or' 87 ) 88 Style = csDropDownList 89 TabOrder = 4 69 90 end 70 91 object ActionList1: TActionList -
branches/generator/Forms/UFormRule.pas
r110 r111 20 20 ButtonOk: TButton; 21 21 ButtonCancel: TButton; 22 ComboBox1: TComboBox; 22 23 EditName: TEdit; 23 24 Label1: TLabel; 25 Label2: TLabel; 24 26 ListView: TListView; 25 27 MenuItem1: TMenuItem; … … 39 41 { private declarations } 40 42 public 41 Rule Items: TRuleItems;43 Rule: TRule; 42 44 procedure UpdateInterface; 43 45 procedure ReloadList; … … 68 70 procedure TFormRule.ListViewData(Sender: TObject; Item: TListItem); 69 71 begin 70 if (Item.Index >= 0) and (Item.Index < Rule Items.Count) then begin71 Item.Caption := Rule Items[Item.Index].Name;72 Item.Data := Rule Items[Item.Index];72 if (Item.Index >= 0) and (Item.Index < Rule.Items.Count) then begin 73 Item.Caption := Rule.Items[Item.Index].GetBNF; 74 Item.Data := Rule.Items[Item.Index]; 73 75 end; 74 76 end; … … 95 97 begin 96 98 NewRuleItem := TRuleItem.Create; 99 NewRuleItem.Grammer := Rule.Grammer; 97 100 FormRuleItem.LoadData(NewRuleItem); 98 101 if FormRuleItem.ShowModal = mrOk then begin 99 102 FormRuleItem.SaveData(NewRuleItem); 100 RuleItems.Add(NewRuleItem); 103 NewRuleItem.ParentRule := Rule; 104 Rule.Items.Add(NewRuleItem); 101 105 ReloadList; 102 106 end else FreeAndNil(NewRuleItem); … … 121 125 for Item in ListView.Items do 122 126 if Item.Selected then 123 Rule Items.Remove(TRuleItem(Item.Data));127 Rule.Items.Remove(TRuleItem(Item.Data)); 124 128 ReloadList; 125 129 end; … … 133 137 procedure TFormRule.ReloadList; 134 138 begin 135 ListView.Items.Count := Rule Items.Count;139 ListView.Items.Count := Rule.Items.Count; 136 140 ListView.Refresh; 137 141 end; … … 139 143 procedure TFormRule.LoadData(Rule: TRule); 140 144 begin 145 Self.Rule := Rule; 146 ComboBox1.ItemIndex := Integer(Rule.RuleType); 141 147 EditName.Text := Rule.Name; 142 Rule Items := Rule.Items;148 Rule.Items := Rule.Items; 143 149 end; 144 150 145 151 procedure TFormRule.SaveData(Rule: TRule); 146 152 begin 153 Rule.RuleType := TRuleType(ComboBox1.ItemIndex); 147 154 Rule.Name := EditName.Text; 148 155 end; -
branches/generator/Forms/UFormRuleItem.lfm
r110 r111 9 9 ClientWidth = 656 10 10 LCLVersion = '1.6.4.0' 11 object Label 1: TLabel12 Left = 2411 object LabelTerminal: TLabel 12 Left = 16 13 13 Height = 24 14 Top = 2415 Width = 5616 Caption = ' Name:'14 Top = 64 15 Width = 79 16 Caption = 'Terminal:' 17 17 ParentColor = False 18 18 end 19 19 object EditName: TEdit 20 Left = 1 3220 Left = 160 21 21 Height = 34 22 Top = 1923 Width = 4 2822 Top = 64 23 Width = 400 24 24 TabOrder = 0 25 25 end … … 42 42 TabOrder = 2 43 43 end 44 object ComboBoxType: TComboBox 45 Left = 160 46 Height = 34 47 Top = 16 48 Width = 400 49 ItemHeight = 0 50 Items.Strings = ( 51 'Terminal' 52 'Non-terminal' 53 ) 54 OnChange = ComboBoxTypeChange 55 Style = csDropDownList 56 TabOrder = 3 57 end 58 object Label2: TLabel 59 Left = 16 60 Height = 24 61 Top = 24 62 Width = 45 63 Caption = 'Type:' 64 ParentColor = False 65 end 66 object LabelNonTerminal: TLabel 67 Left = 16 68 Height = 24 69 Top = 112 70 Width = 119 71 Caption = 'Non-terminal:' 72 ParentColor = False 73 end 74 object ComboBoxNonTerminal: TComboBox 75 Left = 160 76 Height = 36 77 Top = 104 78 Width = 404 79 ItemHeight = 0 80 Style = csDropDownList 81 TabOrder = 4 82 end 44 83 end -
branches/generator/Forms/UFormRuleItem.pas
r110 r111 16 16 ButtonCancel: TButton; 17 17 ButtonOk: TButton; 18 ComboBoxType: TComboBox; 19 ComboBoxNonTerminal: TComboBox; 18 20 EditName: TEdit; 19 Label1: TLabel; 21 LabelTerminal: TLabel; 22 Label2: TLabel; 23 LabelNonTerminal: TLabel; 24 procedure ComboBoxTypeChange(Sender: TObject); 20 25 private 21 { private declarations }26 procedure ReloadNonTerminals(Grammer: TGrammer); 22 27 public 28 RuleItem: TRuleItem; 29 procedure UpdateInterface; 23 30 procedure LoadData(RuleItem: TRuleItem); 24 31 procedure SaveData(RuleItem: TRuleItem); … … 34 41 { TFormRuleItem } 35 42 43 procedure TFormRuleItem.ComboBoxTypeChange(Sender: TObject); 44 begin 45 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 46 UpdateInterface; 47 end; 48 49 procedure TFormRuleItem.ReloadNonTerminals(Grammer: TGrammer); 50 var 51 Rule: TRule; 52 begin 53 ComboBoxNonTerminal.Items.Clear; 54 for Rule in Grammer.Rules do begin 55 ComboBoxNonTerminal.Items.AddObject(Rule.Name, Rule); 56 end; 57 end; 58 59 procedure TFormRuleItem.UpdateInterface; 60 begin 61 EditName.Visible := RuleItem.RuleItemType = ritTerminal; 62 LabelTerminal.Visible := RuleItem.RuleItemType = ritTerminal; 63 ComboBoxNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 64 LabelNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 65 end; 66 36 67 procedure TFormRuleItem.LoadData(RuleItem: TRuleItem); 37 68 begin 38 EditName.Text := RuleItem.Name; 69 Self.RuleItem := RuleItem; 70 ReloadNonTerminals(RuleItem.Grammer); 71 ComboBoxType.ItemIndex := Integer(RuleItem.RuleItemType); 72 ComboBoxNonTerminal.ItemIndex := ComboBoxNonTerminal.Items.IndexOfObject(RuleItem.NonTerminal); 73 EditName.Text := RuleItem.Terminal; 74 UpdateInterface; 39 75 end; 40 76 41 77 procedure TFormRuleItem.SaveData(RuleItem: TRuleItem); 42 78 begin 43 RuleItem.Name := EditName.Text; 79 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 80 if RuleItem.RuleItemType = ritTerminal then RuleItem.Terminal := EditName.Text 81 else if RuleItem.RuleItemType = ritNonTerminal then 82 RuleItem.NonTerminal := TRule(ComboBoxNonTerminal.Items.Objects[ComboBoxNonTerminal.ItemIndex]); 44 83 end; 45 84 -
branches/generator/Forms/UFormRules.lfm
r109 r111 27 27 Height = 24 28 28 Top = 5 29 Width = 7029 Width = 150 30 30 Align = alNone 31 31 AutoSize = True -
branches/generator/Forms/UFormRules.pas
r109 r111 69 69 begin 70 70 NewRule := TRule.Create; 71 NewRule.Grammer := Rules.Grammer; 71 72 FormRule.LoadData(NewRule); 72 73 if FormRule.ShowModal = mrOk then begin -
branches/generator/UCore.pas
r109 r111 19 19 { private declarations } 20 20 public 21 Rules: TRules;21 Grammer: TGrammer; 22 22 end; 23 23 … … 33 33 procedure TCore.DataModuleCreate(Sender: TObject); 34 34 begin 35 Rules := TRules.Create;36 Rules.LoadFromXmlFile('pascal.grm');35 Grammer := TGrammer.Create; 36 Grammer.LoadFromXmlFile('pascal.grm'); 37 37 end; 38 38 39 39 procedure TCore.DataModuleDestroy(Sender: TObject); 40 40 begin 41 Rules.SaveToXmlFile('pascal.grm');42 FreeAndNil( Rules);41 Grammer.SaveToXmlFile('pascal.grm'); 42 FreeAndNil(Grammer); 43 43 end; 44 44 -
branches/generator/URules.pas
r110 r111 9 9 10 10 type 11 TRule = class; 12 TRules = class; 13 TGrammer = class; 14 15 TRuleItemType = (ritTerminal, ritNonTerminal); 11 16 12 17 { TRuleItem } 13 18 14 19 TRuleItem = class 15 Name: string; 20 ParentRule: TRule; 21 RuleItemType: TRuleItemType; 22 Terminal: string; 23 NonTerminalName: string; 24 NonTerminal: TRule; 25 Grammer: TGrammer; 16 26 procedure LoadFromXmlNode(Node: TDOMNode); 17 27 procedure SaveToXmlNode(Node: TDOMNode); 28 function GetBNF: string; 18 29 end; 19 30 … … 21 32 22 33 TRuleItems = class(TFPGObjectList<TRuleItem>) 34 Grammer: TGrammer; 23 35 procedure LoadFromXmlNode(Node: TDOMNode); 24 36 procedure SaveToXmlNode(Node: TDOMNode); 25 37 end; 26 38 39 TRuleType = (rtAnd, rtOr); 40 27 41 { TRule } 28 42 29 43 TRule = class 44 private 45 function GetGrammer: TGrammer; 46 procedure SetGrammer(AValue: TGrammer); 47 public 30 48 Name: string; 31 49 Items: TRuleItems; 50 RuleType: TRuleType; 51 property Grammer: TGrammer read GetGrammer write SetGrammer; 32 52 constructor Create; 33 53 destructor Destroy; override; … … 40 60 41 61 TRules = class(TFPGObjectList<TRule>) 42 FileName: string; 62 Grammer: TGrammer; 63 function FindName(Name: string): TRule; 43 64 procedure LoadFromXmlNode(Node: TDOMNode); 44 65 procedure SaveToXmlNode(Node: TDOMNode); 66 function GetBNF: string; 67 end; 68 69 { TGrammer } 70 71 TGrammer = class 72 FileName: string; 73 Rules: TRules; 45 74 procedure LoadFromXmlFile(FileName: string); 46 75 procedure SaveToXmlFile(FileName: string); 76 constructor Create; 77 destructor Destroy; override; 47 78 function GetBNF: string; 48 79 end; … … 50 81 implementation 51 82 52 { TRuleItem } 53 54 procedure TRuleItem.SaveToXmlNode(Node: TDOMNode); 55 begin 56 WriteString(Node, 'Name', Name); 57 end; 58 59 procedure TRuleItem.LoadFromXmlNode(Node: TDOMNode); 60 begin 61 Name := ReadString(Node, 'Name', ''); 62 end; 63 64 { TRuleItems } 65 66 procedure TRuleItems.SaveToXmlNode(Node: TDOMNode); 67 var 68 RuleItem: TRuleItem; 69 RuleItemNode: TDOMNode; 70 begin 71 for RuleItem in Self do begin 72 RuleItemNode := Node.OwnerDocument.CreateElement('RuleItem'); 73 RuleItem.SaveToXmlNode(RuleItemNode); 74 Node.AppendChild(RuleItemNode); 75 end; 76 end; 77 78 procedure TRuleItems.LoadFromXmlNode(Node: TDOMNode); 79 var 80 RuleItemNode: TDOMNode; 81 RuleItem: TRuleItem; 82 begin 83 RuleItemNode := Node.FirstChild; 84 while Assigned(RuleItemNode) do begin 85 if RuleItemNode.NodeName = 'RuleItem' then begin 86 RuleItem := TRuleItem.Create; 87 RuleItem.LoadFromXmlNode(RuleItemNode); 88 Add(RuleItem); 89 end; 90 RuleItemNode := RuleItemNode.NextSibling; 91 end; 92 end; 93 94 { TRule } 95 96 procedure TRule.SaveToXmlNode(Node: TDOMNode); 97 var 98 RuleItemsNode: TDOMNode; 99 begin 100 WriteString(Node, 'Name', Name); 101 102 RuleItemsNode := Node.OwnerDocument.CreateElement('RuleItems'); 103 Node.AppendChild(RuleItemsNode); 104 Items.SaveToXmlNode(RuleItemsNode); 105 end; 106 107 function TRule.GetBNF: string; 108 var 109 Item: TRuleItem; 110 begin 111 Result := Name + ' ::='; 112 for Item in Items do begin 113 Result := Result + ' ' + Item.Name; 114 end; 115 end; 116 117 constructor TRule.Create; 118 begin 119 Items := TRuleItems.Create; 120 end; 121 122 destructor TRule.Destroy; 123 begin 124 FreeAndNil(Items); 125 inherited Destroy; 126 end; 127 128 procedure TRule.LoadFromXmlNode(Node: TDOMNode); 129 var 130 ItemsNode: TDOMNode; 131 begin 132 Name := ReadString(Node, 'Name', ''); 133 134 ItemsNode := Node.FindNode('RuleItems'); 135 if Assigned(ItemsNode) then begin 136 Items.LoadFromXmlNode(ItemsNode); 137 end; 138 end; 139 140 { TRules } 141 142 procedure TRules.SaveToXmlNode(Node: TDOMNode); 143 var 144 Rule: TRule; 145 RuleNode: TDOMNode; 146 begin 147 for Rule in Self do begin 148 RuleNode := Node.OwnerDocument.CreateElement('Rule'); 149 Rule.SaveToXmlNode(RuleNode); 150 Node.AppendChild(RuleNode); 151 end; 152 end; 153 154 procedure TRules.LoadFromXmlNode(Node: TDOMNode); 155 var 156 RuleNode: TDOMNode; 157 Rule: TRule; 158 begin 159 RuleNode := Node.FirstChild; 160 while Assigned(RuleNode) do begin 161 if RuleNode.NodeName = 'Rule' then begin 162 Rule := TRule.Create; 163 Rule.LoadFromXmlNode(RuleNode); 164 Add(Rule); 165 end; 166 RuleNode := RuleNode.NextSibling; 167 end; 168 end; 169 170 procedure TRules.LoadFromXmlFile(FileName: string); 83 { TGrammer } 84 85 procedure TGrammer.LoadFromXmlFile(FileName: string); 171 86 var 172 87 Doc: TXMLDocument; 173 88 RootNode: TDOMNode; 174 89 RulesNode: TDOMNode; 90 Rule: TRule; 91 RuleItem: TRuleItem; 175 92 begin 176 93 Self.FileName := FileName; 177 Clear;94 Rules.Clear; 178 95 try 179 96 ReadXMLFile(Doc, FileName); … … 183 100 RulesNode := RootNode.FindNode('Rules'); 184 101 if Assigned(RulesNode) then begin 185 LoadFromXmlNode(RulesNode);102 Rules.LoadFromXmlNode(RulesNode); 186 103 end; 187 104 end; … … 189 106 Doc.Free; 190 107 end; 191 end; 192 193 procedure TRules.SaveToXmlFile(FileName: string); 108 109 // Update rule references 110 for Rule in Rules do 111 for RuleItem in Rule.Items do 112 if RuleItem.RuleItemType = ritNonTerminal then 113 RuleItem.NonTerminal := Rules.FindName(RuleItem.NonTerminalName); 114 end; 115 116 procedure TGrammer.SaveToXmlFile(FileName: string); 194 117 var 195 118 Doc: TXMLDocument; … … 205 128 RulesNode := Doc.CreateElement('Rules'); 206 129 RootNode.AppendChild(RulesNode); 207 SaveToXmlNode(RulesNode);130 Rules.SaveToXmlNode(RulesNode); 208 131 209 132 WriteXMLFile(Doc, FileName); … … 213 136 end; 214 137 138 constructor TGrammer.Create; 139 begin 140 Rules := TRules.Create; 141 Rules.Grammer := Self; 142 end; 143 144 destructor TGrammer.Destroy; 145 begin 146 FreeAndNil(Rules); 147 inherited Destroy; 148 end; 149 150 function TGrammer.GetBNF: string; 151 begin 152 Result := Rules.GetBNF; 153 end; 154 155 { TRuleItem } 156 157 procedure TRuleItem.SaveToXmlNode(Node: TDOMNode); 158 begin 159 WriteInteger(Node, 'Type', Integer(RuleItemType)); 160 if RuleItemType = ritTerminal then WriteString(Node, 'Terminal', Terminal) 161 else if RuleItemType = ritNonTerminal then WriteString(Node, 'NonTerminal', NonTerminal.Name) 162 end; 163 164 function TRuleItem.GetBNF: string; 165 begin 166 if RuleItemType = ritTerminal then Result := '"' + Terminal + '"' 167 else if RuleItemType = ritNonTerminal then Result := NonTerminal.Name; 168 end; 169 170 procedure TRuleItem.LoadFromXmlNode(Node: TDOMNode); 171 begin 172 RuleItemType := TRuleItemType(ReadInteger(Node, 'Type', Integer(ritTerminal))); 173 if RuleItemType = ritTerminal then Terminal := ReadString(Node, 'Terminal', '') 174 else if RuleItemType = ritNonTerminal then 175 NonTerminalName := ReadString(Node, 'NonTerminal', ''); 176 end; 177 178 { TRuleItems } 179 180 procedure TRuleItems.SaveToXmlNode(Node: TDOMNode); 181 var 182 RuleItem: TRuleItem; 183 RuleItemNode: TDOMNode; 184 begin 185 for RuleItem in Self do begin 186 RuleItemNode := Node.OwnerDocument.CreateElement('RuleItem'); 187 RuleItem.SaveToXmlNode(RuleItemNode); 188 Node.AppendChild(RuleItemNode); 189 end; 190 end; 191 192 procedure TRuleItems.LoadFromXmlNode(Node: TDOMNode); 193 var 194 RuleItemNode: TDOMNode; 195 RuleItem: TRuleItem; 196 begin 197 RuleItemNode := Node.FirstChild; 198 while Assigned(RuleItemNode) do begin 199 if RuleItemNode.NodeName = 'RuleItem' then begin 200 RuleItem := TRuleItem.Create; 201 RuleItem.Grammer := Grammer; 202 RuleItem.LoadFromXmlNode(RuleItemNode); 203 Add(RuleItem); 204 end; 205 RuleItemNode := RuleItemNode.NextSibling; 206 end; 207 end; 208 209 { TRule } 210 211 procedure TRule.SaveToXmlNode(Node: TDOMNode); 212 var 213 RuleItemsNode: TDOMNode; 214 begin 215 WriteString(Node, 'Name', Name); 216 217 RuleItemsNode := Node.OwnerDocument.CreateElement('RuleItems'); 218 Node.AppendChild(RuleItemsNode); 219 Items.SaveToXmlNode(RuleItemsNode); 220 end; 221 222 function TRule.GetBNF: string; 223 var 224 Item: TRuleItem; 225 begin 226 Result := Name + ' ::= '; 227 for Item in Items do begin 228 if Item <> Items.First then begin 229 if RuleType = rtAnd then Result := Result + ' ' 230 else if RuleType = rtOr then Result := Result + ' | '; 231 end; 232 Result := Result + Item.GetBNF; 233 end; 234 end; 235 236 function TRule.GetGrammer: TGrammer; 237 begin 238 Result := Items.Grammer; 239 end; 240 241 procedure TRule.SetGrammer(AValue: TGrammer); 242 begin 243 Items.Grammer := AValue; 244 end; 245 246 constructor TRule.Create; 247 begin 248 Items := TRuleItems.Create; 249 end; 250 251 destructor TRule.Destroy; 252 begin 253 FreeAndNil(Items); 254 inherited Destroy; 255 end; 256 257 procedure TRule.LoadFromXmlNode(Node: TDOMNode); 258 var 259 ItemsNode: TDOMNode; 260 begin 261 Name := ReadString(Node, 'Name', ''); 262 263 ItemsNode := Node.FindNode('RuleItems'); 264 if Assigned(ItemsNode) then begin 265 Items.LoadFromXmlNode(ItemsNode); 266 end; 267 end; 268 269 { TRules } 270 271 procedure TRules.SaveToXmlNode(Node: TDOMNode); 272 var 273 Rule: TRule; 274 RuleNode: TDOMNode; 275 begin 276 for Rule in Self do begin 277 RuleNode := Node.OwnerDocument.CreateElement('Rule'); 278 Rule.SaveToXmlNode(RuleNode); 279 Node.AppendChild(RuleNode); 280 end; 281 end; 282 283 function TRules.FindName(Name: string): TRule; 284 var 285 I: Integer; 286 begin 287 I := 0; 288 while (I < Count) and (Items[I].Name <> Name) do Inc(I); 289 if I < Count then Result := Items[I] 290 else Result := nil; 291 end; 292 293 procedure TRules.LoadFromXmlNode(Node: TDOMNode); 294 var 295 RuleNode: TDOMNode; 296 Rule: TRule; 297 begin 298 RuleNode := Node.FirstChild; 299 while Assigned(RuleNode) do begin 300 if RuleNode.NodeName = 'Rule' then begin 301 Rule := TRule.Create; 302 Rule.Grammer := Grammer; 303 Rule.LoadFromXmlNode(RuleNode); 304 Add(Rule); 305 end; 306 RuleNode := RuleNode.NextSibling; 307 end; 308 end; 309 215 310 function TRules.GetBNF: string; 216 311 var -
branches/generator/pascal.grm
r110 r111 6 6 <RuleItems> 7 7 <RuleItem> 8 <Name>begin</Name> 8 <Type>0</Type> 9 <Terminal>begin</Terminal> 9 10 </RuleItem> 10 11 <RuleItem> 11 <Name>command</Name> 12 <Type>1</Type> 13 <NonTerminal>Command</NonTerminal> 12 14 </RuleItem> 13 15 <RuleItem> 14 <Name>end</Name> 16 <Type>0</Type> 17 <Terminal>end</Terminal> 15 18 </RuleItem> 16 19 </RuleItems> … … 18 21 <Rule> 19 22 <Name>IfThenElse</Name> 20 <RuleItems/> 23 <RuleItems> 24 <RuleItem> 25 <Type>0</Type> 26 <Terminal>if</Terminal> 27 </RuleItem> 28 <RuleItem> 29 <Type>1</Type> 30 <NonTerminal>Expression</NonTerminal> 31 </RuleItem> 32 <RuleItem> 33 <Type>0</Type> 34 <Terminal>then</Terminal> 35 </RuleItem> 36 <RuleItem> 37 <Type>1</Type> 38 <NonTerminal>Command</NonTerminal> 39 </RuleItem> 40 <RuleItem> 41 <Type>0</Type> 42 <Terminal>else</Terminal> 43 </RuleItem> 44 <RuleItem> 45 <Type>1</Type> 46 <NonTerminal>Command</NonTerminal> 47 </RuleItem> 48 <RuleItem> 49 <Type>0</Type> 50 <Terminal>end</Terminal> 51 </RuleItem> 52 </RuleItems> 21 53 </Rule> 22 54 <Rule> 23 55 <Name>WhileDo</Name> 24 <RuleItems/> 56 <RuleItems> 57 <RuleItem> 58 <Type>0</Type> 59 <Terminal>while</Terminal> 60 </RuleItem> 61 <RuleItem> 62 <Type>1</Type> 63 <NonTerminal>Expression</NonTerminal> 64 </RuleItem> 65 <RuleItem> 66 <Type>0</Type> 67 <Terminal>do</Terminal> 68 </RuleItem> 69 <RuleItem> 70 <Type>1</Type> 71 <NonTerminal>Command</NonTerminal> 72 </RuleItem> 73 </RuleItems> 25 74 </Rule> 26 75 <Rule> 27 76 <Name>RepeatUntil</Name> 28 <RuleItems/> 77 <RuleItems> 78 <RuleItem> 79 <Type>0</Type> 80 <Terminal>repeat</Terminal> 81 </RuleItem> 82 <RuleItem> 83 <Type>1</Type> 84 <NonTerminal>Command</NonTerminal> 85 </RuleItem> 86 <RuleItem> 87 <Type>0</Type> 88 <Terminal>until</Terminal> 89 </RuleItem> 90 <RuleItem> 91 <Type>1</Type> 92 <NonTerminal>Expression</NonTerminal> 93 </RuleItem> 94 </RuleItems> 29 95 </Rule> 30 96 <Rule> … … 42 108 <Rule> 43 109 <Name>Assignment</Name> 44 <RuleItems/> 110 <RuleItems> 111 <RuleItem> 112 <Type>1</Type> 113 <NonTerminal>Variable</NonTerminal> 114 </RuleItem> 115 <RuleItem> 116 <Type>0</Type> 117 <Terminal>:=</Terminal> 118 </RuleItem> 119 <RuleItem> 120 <Type>1</Type> 121 <NonTerminal>Expression</NonTerminal> 122 </RuleItem> 123 </RuleItems> 45 124 </Rule> 46 125 <Rule> … … 48 127 <RuleItems/> 49 128 </Rule> 129 <Rule> 130 <Name>Expression</Name> 131 <RuleItems/> 132 </Rule> 133 <Rule> 134 <Name>Variable</Name> 135 <RuleItems/> 136 </Rule> 50 137 </Rules> 51 138 </GrammerProject>
Note:
See TracChangeset
for help on using the changeset viewer.