Changeset 20


Ignore:
Timestamp:
Jun 25, 2012, 1:24:13 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Počáteční návrh editoru a kompilátoru pro i8051.
Location:
branches
Files:
28 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Void/UCompilator.pas

    r19 r20  
    152152var
    153153  RuleProgram, RuleBlock, RuleDeclaration, RuleStatement, RuleConstant,
    154   RuleVariable, RuleFunction: TGrammerRule;
     154  RuleVariable, RuleFunction, RuleConstantBlock: TGrammerRule;
    155155begin
    156156  Grammer := TGrammer.Create;
     
    160160      Name := 'ConstantDefinition';
    161161      RuleType := rtSequence;
     162      AddTerminal('', ttIdentifier, False, False);
     163      AddTerminal('=', ttSymbol, False, False);
     164      AddTerminal('', ttNumber, False, False);
    162165    end;
    163166    Rules.Add(RuleConstantDefinition);
     167
     168    RuleConstantBlock := TGrammerRule.Create;
     169    with RuleConstantBlock do begin
     170      Name := 'ConstantBlock';
     171      RuleType := rtSequence;
     172      AddTerminal(',', ttISymbol, False, False);
     173      AddRule(RuleConstantDefinition, False, False);
     174    end;
     175    Rules.Add(RuleConstantBlock);
    164176
    165177    RuleConstant := TGrammerRule.Create;
     
    169181      AddTerminal('const', ttIdentifier, False, False);
    170182      AddRule(RuleConstantDefinition, False, False);
     183      AddRule(RuleConstantBlock, True, True);
    171184    end;
    172185    Rules.Add(RuleConstant);
     
    179192    Rules.Add(RuleFunction);
    180193
     194    RuleVariableBlock := TGrammerRule.Create;
     195    with RuleVariableBlock do begin
     196      Name := 'VariableBlock';
     197      RuleType := rtSequence;
     198      AddTerminal(',', ttIdentifier, False, False);
     199      AddTerminal('', ttIdentifier, False, False);
     200    end;
     201    Rules.Add(RuleVariableBlock);
     202
    181203    RuleVariable := TGrammerRule.Create;
    182204    with RuleVariable do begin
    183205      Name := 'Variable';
    184206      RuleType := rtSequence;
     207      AddTerminal('var', ttIdentifier, False, False);
     208      AddTerminal('', ttIdentifier, False, False);
     209      AddRule(RuleVariableBlock, True, True);
    185210    end;
    186211    Rules.Add(RuleVariable);
Note: See TracChangeset for help on using the changeset viewer.