Browse Source

Force declarations at the beginning

Arnaud Vergnet 3 years ago
parent
commit
7d65980c4f
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      as.y

+ 8
- 4
as.y View File

49
 
49
 
50
 S : Main ;
50
 S : Main ;
51
 
51
 
52
-Main : tINT tMAIN tPO Params tPF Body ;
52
+Main : tINT tMAIN tPO Params tPF MainBody ;
53
 
53
 
54
 Params : | Param SuiteParams ;
54
 Params : | Param SuiteParams ;
55
 Param : tINT tID ;
55
 Param : tINT tID ;
56
 
56
 
57
 SuiteParams : tVIRG Param SuiteParams ;
57
 SuiteParams : tVIRG Param SuiteParams ;
58
 
58
 
59
+MainBody : tAO Declarations Instructions tAF ;
60
+
59
 Body : tAO Instructions tAF ;
61
 Body : tAO Instructions tAF ;
60
 
62
 
61
 Instructions : Instruction Instructions | ;
63
 Instructions : Instruction Instructions | ;
62
 
64
 
63
-Instruction : Aff | Printf  | If | Declaration ;
65
+Instruction : Aff | Printf  | If ;
64
 
66
 
65
 Aff : tID tEQ E tPV ;
67
 Aff : tID tEQ E tPV ;
66
 
68
 
67
 E : tNB | tID | E tADD E | E tMUL E | E tSUB E | E tDIV E | tPO E tPF | tSUB E ;
69
 E : tNB | tID | E tADD E | E tMUL E | E tSUB E | E tDIV E | tPO E tPF | tSUB E ;
68
 
70
 
69
-DeclarationBody : tID tVIRG DeclarationBody | tID ;
71
+Declarations : | Declaration Declarations ;
72
+
73
+Declaration : DeclarationInt | DeclarationConst ;
70
 
74
 
71
 DeclarationInt : tINT DeclarationBody tPV ;
75
 DeclarationInt : tINT DeclarationBody tPV ;
72
 
76
 
73
 DeclarationConst : tCONST DeclarationBody tPV ;
77
 DeclarationConst : tCONST DeclarationBody tPV ;
74
 
78
 
75
-Declaration : DeclarationInt | DeclarationConst ;
79
+DeclarationBody : tID tVIRG DeclarationBody | tID ;
76
 
80
 
77
 If : IfSimple | IfElse ;
81
 If : IfSimple | IfElse ;
78
 
82
 

Loading…
Cancel
Save