@@ -21,6 +21,11 @@ let rec iterate_n f x = function
2121 | n -> iterate_n f (f x) (n - 1 )
2222let nest_unsized_array basic_type n =
2323 iterate_n (fun t -> UnsizedType. UArray t) basic_type n
24+
25+ (* $sloc and $symbolstartpos generates code using !=, which
26+ Core_kernel considers to be an error.
27+ *)
28+ let (!= ) = Stdlib. (!= )
2429% }
2530
2631% token FUNCTIONBLOCK DATABLOCK TRANSFORMEDDATABLOCK PARAMETERSBLOCK
@@ -93,7 +98,7 @@ program:
9398 let () =
9499 match (ofb, odb, otdb, opb, otpb, omb, ogb) with
95100 | None , None , None , None , None , None , None ->
96- Input_warnings. empty (fst $ loc ).pos_fname
101+ Input_warnings. empty ($ startpos ).pos_fname
97102 | _ -> ()
98103 in
99104 { functionblock= ofb
@@ -160,11 +165,19 @@ generated_quantities_block:
160165identifier:
161166 | id= IDENTIFIER { build_id id $ loc }
162167 | TRUNCATE { build_id " T" $ loc}
163- | OFFSET { build_id " offset" $ loc}
164- | MULTIPLIER { build_id " multiplier" $ loc}
165- | LOWER { build_id " lower" $ loc}
166- | UPPER { build_id " upper" $ loc}
167- | ARRAY { build_id " array" $ loc}
168+ | id_and_v = future_keyword
169+ {
170+ let id, v = id_and_v in
171+ Input_warnings. future_keyword id.name v $ loc;
172+ id
173+ }
174+
175+ future_keyword:
176+ | OFFSET { build_id " offset" $ loc, " 2.32.0" }
177+ | MULTIPLIER { build_id " multiplier" $ loc, " 2.32.0" }
178+ | LOWER { build_id " lower" $ loc, " 2.32.0" }
179+ | UPPER { build_id " upper" $ loc, " 2.32.0" }
180+ | ARRAY { build_id " array" $ loc, " 2.32.0" }
168181
169182decl_identifier:
170183 | id= identifier { id }
@@ -342,6 +355,7 @@ decl(type_rule, rhs):
342355 in
343356 let dims = match dims_opt with
344357 | Some ({expr = Indexed ({expr = Variable {name ="array" ; _} ; _} , ixs ); _} ) ->
358+ Input_warnings. drop_array_future () ;
345359 (match int_ixs ixs with
346360 | Some sizes -> sizes
347361 | None -> error " Dimensions should be expressions, not multiple or range indexing." )
@@ -358,27 +372,7 @@ decl(type_rule, rhs):
358372 ; is_global
359373 }
360374 ; smeta= {
361- loc=
362- (* From the docs:
363- We remark that, if the current production has an empty right-hand side,
364- then $startpos and $endpos are equal, and (by convention) are the end
365- position of the most recently parsed symbol (that is, the symbol that
366- happens to be on top of the automaton’s stack when this production is
367- reduced). If the current production has a nonempty right-hand side,
368- then $startpos is the same as $startpos($1) and $endpos is the same
369- as $endpos($n), where n is the length of the right-hand side.
370-
371-
372- So when dims_opt is empty, it uses the preview token as its startpos,
373- but that makes the whole declaration think it starts at the previous
374- token. Sadly, $sloc and $symbolstartpos generates code using !=, which
375- Core_kernel considers to be an error.
376- *)
377- let startpos = match dims_opt with
378- | None -> $ startpos(ty)
379- | Some _ -> $ startpos
380- in
381- Location_span. of_positions_exn (startpos, $ endpos)
375+ loc= Location_span. of_positions_exn $ sloc
382376 }
383377 })
384378 )}
0 commit comments