@@ -40,8 +40,7 @@ let unclosed_error what startpos endpos =
40
40
syntax_error (Printf. sprintf " Unclosed %s" what) startpos endpos
41
41
% }
42
42
43
- % token < string > CHAR_LITERAL STRING_LITERAL IDENT MOD_IDENT PREDEFINED_CLASS
44
- % token < int > INT
43
+ % token < string > CHAR_LITERAL STRING_LITERAL IDENT MOD_IDENT PREDEFINED_CLASS INT
45
44
% token SLASH LPAREN RPAREN LBRACKET RBRACKET CARET LBRACE RBRACE EMPTY_STR
46
45
% token DASH BAR STAR PLUS QUESTION UNDERSCORE COLON EQUAL AS PIPE
47
46
% token INT_CONVERTER FLOAT_CONVERTER EOF
@@ -108,15 +107,16 @@ atom_expr:
108
107
wrap_loc $ startpos $ endpos (Opt $ 1 )
109
108
}
110
109
| basic_atom LBRACE n = INT RBRACE {
110
+ let n = int_of_string n in
111
111
let repeat_loc = wrap_loc $ startpos($ 2 ) $ endpos($ 4 ) (n, Some n) in
112
112
wrap_loc $ startpos $ endpos (Repeat (repeat_loc, $ 1 ))
113
113
}
114
114
| basic_atom LBRACE min = INT DASH max = INT RBRACE {
115
- let repeat_loc = wrap_loc $ startpos($ 2 ) $ endpos($ 6 ) (min, Some max) in
115
+ let repeat_loc = wrap_loc $ startpos($ 2 ) $ endpos($ 6 ) (int_of_string min, Some (int_of_string max) ) in
116
116
wrap_loc $ startpos $ endpos (Repeat (repeat_loc, $ 1 ))
117
117
}
118
118
| basic_atom LBRACE min = INT DASH RBRACE {
119
- let repeat_loc = wrap_loc $ startpos($ 2 ) $ endpos($ 5 ) (min, None ) in
119
+ let repeat_loc = wrap_loc $ startpos($ 2 ) $ endpos($ 5 ) (int_of_string min, None ) in
120
120
wrap_loc $ startpos $ endpos (Repeat (repeat_loc, $ 1 ))
121
121
}
122
122
(* error cases for repetition *)
@@ -265,5 +265,6 @@ char_set_item:
265
265
| CHAR_LITERAL DASH CHAR_LITERAL { $ 1 ^ " -" ^ $ 3 }
266
266
| CHAR_LITERAL DASH { missing_error " character after '-' in range" $ startpos($ 2 ) $ endpos }
267
267
| STRING_LITERAL { $ 1 }
268
+ | INT { $ 1 }
268
269
| PREDEFINED_CLASS { $ 1 }
269
270
| IDENT { $ 1 }
0 commit comments