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,30 +49,34 @@
49 49
 
50 50
 S : Main ;
51 51
 
52
-Main : tINT tMAIN tPO Params tPF Body ;
52
+Main : tINT tMAIN tPO Params tPF MainBody ;
53 53
 
54 54
 Params : | Param SuiteParams ;
55 55
 Param : tINT tID ;
56 56
 
57 57
 SuiteParams : tVIRG Param SuiteParams ;
58 58
 
59
+MainBody : tAO Declarations Instructions tAF ;
60
+
59 61
 Body : tAO Instructions tAF ;
60 62
 
61 63
 Instructions : Instruction Instructions | ;
62 64
 
63
-Instruction : Aff | Printf  | If | Declaration ;
65
+Instruction : Aff | Printf  | If ;
64 66
 
65 67
 Aff : tID tEQ E tPV ;
66 68
 
67 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 75
 DeclarationInt : tINT DeclarationBody tPV ;
72 76
 
73 77
 DeclarationConst : tCONST DeclarationBody tPV ;
74 78
 
75
-Declaration : DeclarationInt | DeclarationConst ;
79
+DeclarationBody : tID tVIRG DeclarationBody | tID ;
76 80
 
77 81
 If : IfSimple | IfElse ;
78 82
 

Loading…
Cancel
Save