Skip to content

Commit f2bcfc3

Browse files
author
KEYU PU
committed
class: using lowerIdent for method name and attribute name
1 parent 2aea52d commit f2bcfc3

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Parsing/LexicalAnalyser.mll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
| CLASS -> print_string "CLASS"
4040
| NEW -> print_string "NEW"
4141
| THIS -> print_string "THIS"
42+
| STATIC -> print_string "STATIC"
43+
| TYPE s -> print_string "TYPE("; print_string s; print_string ")"
4244

4345

4446
open Lexing

Parsing/SyntaxAnalyser.mly

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
/* Keywords */
3434
%token IF ELSE
3535

36+
/* Declarations of variables */
37+
%token <string> TYPE
38+
3639
/* Start symbols and types */
3740
%start expression
3841
%type < Expression.expression list> expression
@@ -84,24 +87,24 @@ attribute_or_method:
8487
| comment* m=method
8588

8689
method:
87-
| STATIC t=TYPE id=VAR LPAR p=params RPAR LBRACE e=expr RBRACE
90+
| STATIC t=TYPE id=LOWERIDENT LPAR p=params RPAR LBRACE e=expr RBRACE
8891
{ Method(true, t, id, p, e) }
89-
| STATIC t=TYPE id=VAR LPAR RPAR LBRACE e=expr RBRACE
92+
| STATIC t=TYPE id=LOWERIDENT LPAR RPAR LBRACE e=expr RBRACE
9093
{ Method(true, t, id, [], e) }
91-
| t=TYPE id=VAR LPAR p=params RPAR LBRACE e=expr RBRACE
94+
| t=TYPE id=LOWERIDENT LPAR p=params RPAR LBRACE e=expr RBRACE
9295
{ Method(false, t, id, p, e) }
93-
| t=TYPE id=VAR LPAR RPAR LBRACE e=expr RBRACE
96+
| t=TYPE id=LOWERIDENT LPAR RPAR LBRACE e=expr RBRACE
9497
{ Method(false, t, id, [], e) }
9598

9699
param:
97-
| t=TYPE id=VAR
100+
| t=TYPE id=LOWERIDENT
98101
{ Param(t,id) }
99102

100103
params:
101104
| { [] }
102-
| t=TYPE id=VAR
105+
| t=TYPE id=LOWERIDENT
103106
{ [Param(t,id)] }
104-
| t=TYPE id=VAR COMMA r=param+
107+
| t=TYPE id=LOWERIDENT COMMA r=param+
105108
{ Param(t,id) :: r}
106109

107110
expr:

0 commit comments

Comments
 (0)