Simon Wright <[email protected]> writes:

> If I put my cursor on line 101 ant press TAB, the message shown by C-c
> C-f is

point location when you invoke C-c C-f is irrelevant; point is moved to
the error.

>   normalize_xmi-model-association_classes.adb:116:37: too many
> parallel parsers required; simplify grammar, or increase
> wisi-parse-max-parallel’

I can reproduce this. 

> wisi-parse-max-parallel is set to 15, I tried setting it to 30 but no
> change.

That moves the error deeper in the code; going to 60 allows the parse to
succeed (with a noticeable delay).

> I realise that this code is one where insisting on max line length of
> 79 makes for uncomfortable reading. Any thoughts on how it might be
> reorganised?

Subroutines for each case, instead of a multi-nested case statement.

Replacing the leaves in 'case E1.Lower' with subroutines fixes the
parsing.

Using ada-indent-when = 0 would also help readability.


A better fix is to remove the grammar ambiguity. It is due to allowing
an empty list of alternatives in a case statement:

case foo is
end case;

The intent of this is to make it easy to type a new case statement that
passes the parser.

On the other hand, the 'case' skeleton (in ada-skel.el) expands to:

case  is
when =>
end case;

which has a 'when', so it doesn't require this relaxation. 

However, the skeleton expansion does not have an expression after
'case', so it fails the parser. That's easily fixed by changing
'expression' to 'expression_opt' in the case_statement in
ada-grammar.wy.

My stated requirement on the relaxed syntax in the parser is to succeed
on all code generated by ada-skel. Apparently I need to write more tests.

I think it's clear I should drop allowing a case with no 'when', in
order to support deeply nested case statements.

Here's a patch (also in ada-france):

============================================================
--- ada-grammar.wy      2b4ac85eae3684001a5dbecc8b1bb44f1e59d5cc
+++ ada-grammar.wy      4115b2ce1598091c40692cf4971dffa1a569c774
@@ -208,7 +208,6 @@
 %conflict SHIFT/REDUCE in state actual_parameter_part, attribute_designator on 
token LEFT_PAREN
 %conflict SHIFT/REDUCE in state association_opt, name on token EQUAL_GREATER
 %conflict SHIFT/REDUCE in state attribute_reference, attribute_designator on 
token TICK
-%conflict SHIFT/REDUCE in state case_statement_alternative, 
case_statement_alternative_list on token WHEN
 %conflict SHIFT/REDUCE in state formal_derived_type_definition, 
formal_derived_type_definition on token WITH
 %conflict SHIFT/REDUCE in state label_opt, label_opt on token IDENTIFIER
 %conflict SHIFT/REDUCE in state name, discrete_subtype_definition on token 
RIGHT_PAREN
@@ -476,7 +475,7 @@ case_statement
   ;
 
 case_statement
-  : CASE expression IS case_statement_alternative_list END CASE SEMICOLON
+  : CASE expression_opt IS case_statement_alternative_list END CASE SEMICOLON
     (progn
       (wisi-statement-action 1 'block-start 3 'block-middle 5 'block-end 7 
'statement-end)
       (wisi-containing-action 1 2)
@@ -492,9 +491,11 @@ case_statement_alternative
       (wisi-containing-action 3 4))
   ;
 
+;; We don't allow an empty list here; that leads to parallel parser
+;; explosion in nested case statements. Note that ada-skel-case
+;; inserts an empty 'when =>'
 case_statement_alternative_list
-  : ;; empty
-  | case_statement_alternative
+  : case_statement_alternative
   | case_statement_alternative_list case_statement_alternative
   ;
 
-- 
-- Stephe

_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org

Reply via email to