Ignore:
Timestamp:
Nov 10, 2009, 10:27:21 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Rozdělení jednotek pro generování výstupů do samostatných souborů.
  • Přidáno: Generátor kódu pro procesor Z80.
  • Přidáno: Parsování celých čísel.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Void/UCompilator.pas

    r15 r16  
    5454        if Parser.TokenType <> ttWhiteSpace then DoError('Expect white space');
    5555        Parser.ParseNextToken;
    56         if Parser.TokenType <> ttString then DoError('Expect string');
     56        if Parser.TokenType <> ttIdentifier then DoError('Expect program name')
     57          else Module.Name := Parser.TokenValue;
    5758        Parser.ParseNextToken;
    5859        if (Parser.TokenType <> ttSymbol) and (Parser.TokenValue <> ';') then DoError('Expect ;');
     
    184185          if Assigned(Variable) then begin
    185186            Parser.ParseNextToken;
    186             if Parser.TokenType <> ttWhiteSpace then DoError('Expected white space');
    187             Parser.ParseNextToken;
     187            if Parser.TokenType = ttWhiteSpace then Parser.ParseNextToken;
    188188            if (Parser.TokenType <> ttSymbol) and (Parser.TokenValue = ':=') then
    189189              DoError('Expected :=');
    190190            Parser.ParseNextToken;
    191             if Parser.TokenType <> ttWhiteSpace then DoError('Expected white space');
    192             Parser.ParseNextToken;
     191            if Parser.TokenType = ttWhiteSpace then Parser.ParseNextToken;
    193192            Value := Parser.TokenValue;
    194193            if Parser.TokenType = ttIdentifier then begin
     
    222221                end;
    223222              end;
    224             end else DoError('Expected variable or string')
     223            end else if Parser.TokenType = ttNumber then begin
     224              with TCommand(Commands[Commands.Add(TCommand.Create)]) do begin
     225                Name := 'Assignment';
     226                with TVariableValue(Parameters[Parameters.Add(TVariableValue.Create)]) do begin
     227                  ValueType := vtVariable;
     228                  VariableDef := Variable;
     229                end;
     230                with TVariableValue(Parameters[Parameters.Add(TVariableValue.Create)]) do begin
     231                  ValueType := vtNumber;
     232                  NumberConstant := StrToInt(Parser.TokenValue);
     233                end;
     234              end;
     235            end else DoError('Expected variable or string or number')
    225236          end else DoError('Unknown command ' + CommandName);
    226237        end;
Note: See TracChangeset for help on using the changeset viewer.