The parser cannot decide between alt 1 and alt 2 of entity_decl for an id because for some object_name => name and function_name => name. Either expansion works.
The solution is to just comment out (or delete) the second alt because the first alt covers it.
The parser cannot distinguish between alt 1 and 2 of array_spec because input 1 matches either.
explicit-shape-spec (explicit-chape-spec) and explicit-shape-bounds-spec are described in Section 8.5.8.2.
It is probably safe to comment out (or delete) the alt for explicit_shape_bounds_spec (and corresponding rule) because the syntax is subsumed by explicit_shape_spec_list/explicit_shape_spec.
This rule has conflicting alts 2 (designator), 4 (structure_constructor), and 7 (function_reference) for input reshape(arr2,(/3,3/))if. The problem is that they all can derive the same damn string. The only difference between them is based on type information, which does not--and should not--be in the parser grammar. These alts need to be merged.
entity_decl
https://github.com/kaby76/fortran/blob/ba846bbdea9df98428d094137d2adbe156f86207/FortranParser.g4#L926-L931
The parser cannot decide between alt 1 and alt 2 of entity_decl for an id because for some object_name => name and function_name => name. Either expansion works.
The solution is to just comment out (or delete) the second alt because the first alt covers it.
array_spec
https://github.com/kaby76/fortran/blob/ba846bbdea9df98428d094137d2adbe156f86207/FortranParser.g4#L977-L987
The parser cannot distinguish between alt 1 and 2 of array_spec because input
1
matches either.explicit-shape-spec (explicit-chape-spec) and explicit-shape-bounds-spec are described in Section 8.5.8.2.
It is probably safe to comment out (or delete) the alt for
explicit_shape_bounds_spec
(and corresponding rule) because the syntax is subsumed byexplicit_shape_spec_list/explicit_shape_spec
.designator
https://github.com/kaby76/fortran/blob/ba846bbdea9df98428d094137d2adbe156f86207/FortranParser.g4#L1277-L1286
This rule has a number of problems.
id
with alts 1, 2, 3, 4, 5. Alts 4 and 5 occur only because of alts 1, 2, and 3, but appear on the list due to left recursion.It seems I can rewrite
designator
as follows:primary
https://github.com/kaby76/fortran/blob/ba846bbdea9df98428d094137d2adbe156f86207/FortranParser.g4#L1496-L1508
This rule has conflicting alts 2 (
designator
), 4 (structure_constructor
), and 7 (function_reference
) for inputreshape(arr2,(/3,3/))if
. The problem is that they all can derive the same damn string. The only difference between them is based on type information, which does not--and should not--be in the parser grammar. These alts need to be merged.With these four changes, examples//flang/test/f90_correct/src/intrinsic_pack.f90 runtime drops from ~20s to ~3s.