Changeset 140 for branches/easy compiler/UCompiler.pas
- Timestamp:
- Jan 16, 2018, 10:38:33 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/easy compiler/UCompiler.pas
r139 r140 159 159 Instruction: TSourceInstruction; 160 160 NewReference: TSourceReference; 161 Funct: TSourceFunction; 162 Param: TSourceFunctionParameter; 161 163 162 164 function ParseReference: TSourceReference; … … 171 173 NewReference := TSourceReferenceVariable.Create; 172 174 TSourceReferenceVariable(NewReference).Variable := 173 Code.Variables. Find(Token.Text);175 Code.Variables.Search(Token.Text); 174 176 if TSourceReferenceVariable(NewReference).Variable = nil then 175 177 raise Exception.Create('Variable not found: ' + Token.Text); … … 184 186 NewReference := TSourceReferenceVariable.Create; 185 187 TSourceReferenceVariable(NewReference).Variable := 186 Code.Variables. Find(Token.Text);188 Code.Variables.Search(Token.Text); 187 189 if TSourceReferenceVariable(NewReference).Variable = nil then begin 188 190 if Initialize then … … 201 203 if Token.Kind = stIdentifier then begin 202 204 Keyword := LowerCase(Token.Text); 203 if Keyword = 'print' then begin 205 Funct := Code.Functions.Search(Keyword); 206 if Assigned(Funct) then begin 204 207 Instruction := TSourceInstructionFunction.Create; 205 TSourceInstructionFunction(Instruction).Name := 'print'; 206 TSourceInstructionFunction(Instruction).AddParameter(ParseReference); 207 Code.Instructions.Add(Instruction); 208 end else 209 if Keyword = 'println' then begin 210 Instruction := TSourceInstructionFunction.Create; 211 TSourceInstructionFunction(Instruction).Name := 'println'; 212 TSourceInstructionFunction(Instruction).AddParameter(ParseReference); 213 Code.Instructions.Add(Instruction); 214 end else 215 if Keyword = 'assign' then begin 216 Instruction := TSourceInstructionFunction.Create; 217 TSourceInstructionFunction(Instruction).Name := 'assign'; 218 TSourceInstructionFunction(Instruction).AddParameter(ParseReferenceVariable(True)); 219 TSourceInstructionFunction(Instruction).AddParameter(ParseReference); 208 TSourceInstructionFunction(Instruction).Name := Keyword; 209 for Param in Funct.Parameters do 210 if Param.Kind = pkString then begin 211 TSourceInstructionFunction(Instruction).AddParameter(ParseReference) 212 end else 213 if Param.Kind = pkVariable then begin 214 TSourceInstructionFunction(Instruction).AddParameter(ParseReferenceVariable(True)); 215 end else 216 raise Exception.Create('Unsupported parameter type.'); 220 217 Code.Instructions.Add(Instruction); 221 218 end else raise Exception.Create('Unsupported keyword: ' + Token.Text);
Note:
See TracChangeset
for help on using the changeset viewer.