Stephen Leake <[email protected]> writes:

> Piotr Trojanek <[email protected]> writes:
>
>> with the latest monotone branch org.emacs.ada-mode and I get a parser
>> syntax error on code with conditional expression as an actual
>> parameter.
>>
>> A quick look at the ada-grammar.wy suggest that this is not yet
>> supported by the grammar definition. Test attached. Hope this helps.
>
> Thanks for the test.
>
> It accepts:
>
>    Tmp : Boolean := Id ((if True then True else True));
>
> So you can use that as a workaround.
>
> I remember there is some rule that allows removing the doubled parens in
> this situation, but now I can't find it. I've posted on c.l.a about it;
> when I find the rule, I'll fix ada-grammary.wy.

The rules for removing parens around conditional_expression and
quantified_expression are in 4.5.7(7) and 4.5.8(4).

I had 4.5.7(7) implemented in some places, but not all. I've added the
rest, and also added 4.5.8(4) (they are the same places).

Patch attached.

Looks like it's time for another release. But I've got a couple of
outstanding issues to resolve, and I just had an idea that might speed
up the parser. So it will still be a while yet ;).

-- 
-- Stephe
#
# old_revision [2c009a872539b182a20256f148e8f8d13d5fd265]
# new_revision [afd89e91dcf1dfdf82fc17889fa905321a1120e6]
#
# patch "ada-grammar.wy"
#  from [c58d885764d7918d16bf5992ec88d36055de39a7]
#    to [b74c18e95615bec588eba003af389ff7a9bcf0b6]
#
============================================================
--- ada-grammar.wy	c58d885764d7918d16bf5992ec88d36055de39a7
+++ ada-grammar.wy	b74c18e95615bec588eba003af389ff7a9bcf0b6
@@ -175,6 +175,42 @@
 ;; known conflicts that are resolved by generalized LALR parser
 %conflict REDUCE/REDUCE in state abstract_limited_opt, abstract_limited_synchronized_opt on token NEW
 %conflict REDUCE/REDUCE in state abstract_limited_synchronized_opt, abstract_limited_opt on token NEW
+%conflict REDUCE/REDUCE in state aggregate, primary on token AMPERSAND
+%conflict REDUCE/REDUCE in state aggregate, primary on token AND
+%conflict REDUCE/REDUCE in state aggregate, primary on token BAR
+%conflict REDUCE/REDUCE in state aggregate, primary on token COLON_EQUAL
+%conflict REDUCE/REDUCE in state aggregate, primary on token COMMA
+%conflict REDUCE/REDUCE in state aggregate, primary on token DIGITS
+%conflict REDUCE/REDUCE in state aggregate, primary on token DO
+%conflict REDUCE/REDUCE in state aggregate, primary on token DOT_DOT
+%conflict REDUCE/REDUCE in state aggregate, primary on token ELSE
+%conflict REDUCE/REDUCE in state aggregate, primary on token ELSIF
+%conflict REDUCE/REDUCE in state aggregate, primary on token EQUAL
+%conflict REDUCE/REDUCE in state aggregate, primary on token EQUAL_GREATER
+%conflict REDUCE/REDUCE in state aggregate, primary on token GREATER
+%conflict REDUCE/REDUCE in state aggregate, primary on token GREATER_EQUAL
+%conflict REDUCE/REDUCE in state aggregate, primary on token IN
+%conflict REDUCE/REDUCE in state aggregate, primary on token IS
+%conflict REDUCE/REDUCE in state aggregate, primary on token LESS
+%conflict REDUCE/REDUCE in state aggregate, primary on token LESS_EQUAL
+%conflict REDUCE/REDUCE in state aggregate, primary on token LOOP
+%conflict REDUCE/REDUCE in state aggregate, primary on token MINUS
+%conflict REDUCE/REDUCE in state aggregate, primary on token MOD
+%conflict REDUCE/REDUCE in state aggregate, primary on token NOT
+%conflict REDUCE/REDUCE in state aggregate, primary on token OF
+%conflict REDUCE/REDUCE in state aggregate, primary on token OR
+%conflict REDUCE/REDUCE in state aggregate, primary on token PLUS
+%conflict REDUCE/REDUCE in state aggregate, primary on token RANGE
+%conflict REDUCE/REDUCE in state aggregate, primary on token REM
+%conflict REDUCE/REDUCE in state aggregate, primary on token RIGHT_PAREN
+%conflict REDUCE/REDUCE in state aggregate, primary on token SEMICOLON
+%conflict REDUCE/REDUCE in state aggregate, primary on token SLASH
+%conflict REDUCE/REDUCE in state aggregate, primary on token SLASH_EQUAL
+%conflict REDUCE/REDUCE in state aggregate, primary on token STAR
+%conflict REDUCE/REDUCE in state aggregate, primary on token STAR_STAR
+%conflict REDUCE/REDUCE in state aggregate, primary on token THEN
+%conflict REDUCE/REDUCE in state aggregate, primary on token WITH
+%conflict REDUCE/REDUCE in state aggregate, primary on token XOR
 %conflict REDUCE/REDUCE in state choice_relation, relation on token AND
 %conflict REDUCE/REDUCE in state choice_relation, relation on token OR
 %conflict REDUCE/REDUCE in state choice_relation, relation on token XOR
@@ -195,7 +231,6 @@
 %conflict SHIFT/REDUCE in state aspect_clause, name on token USE
 %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_expression_alternative_list, case_expression on token COMMA
 %conflict SHIFT/REDUCE in state declaration, aliased_opt on token CONSTANT
 %conflict SHIFT/REDUCE in state expression_function_declaration, subprogram_specification on token IS
 %conflict SHIFT/REDUCE in state formal_derived_type_definition, formal_derived_type_definition on token WITH
@@ -306,11 +341,6 @@ actual_parameter_part
     (progn
       (wisi-statement-action [1 open-paren 3 close-paren])
       (wisi-containing-action 1 2))
- ;; ARM 4.5.7(7), ARM 4.5.8(4) allow ( conditional|quantified_expression ) instead of (( ... ))
-  | LEFT_PAREN conditional_quantified_expression RIGHT_PAREN
-    (progn
-      (wisi-statement-action [1 open-paren 3 close-paren])
-      (wisi-containing-action 1 2))
   ;
 
 actual_parameter_part_opt
@@ -329,11 +359,15 @@ aggregate
       (wisi-containing-action 1 2)
       (wisi-containing-action 1 3)
       (wisi-containing-action 3 4))
- ;; ARM 4.5.7(7), ARM 4.5.8(4) allow ( conditional|quantified_expression ) instead of (( ... ))
-  | LEFT_PAREN conditional_quantified_expression RIGHT_PAREN
+  | LEFT_PAREN case_expression RIGHT_PAREN
     (progn
       (wisi-statement-action [1 open-paren 3 close-paren])
       (wisi-containing-action 1 2))
+ ;; ARM 4.5.7 7 allows ( conditional_expression ) instead of (( conditional_expression ))
+  | LEFT_PAREN if_expression RIGHT_PAREN
+    (progn
+      (wisi-statement-action [1 open-paren 3 close-paren])
+      (wisi-containing-action 1 2))
   | LEFT_PAREN expression WITH NULL RECORD RIGHT_PAREN ;; extension_aggregate with null record
     (progn
       (wisi-statement-action [1 open-paren 3 statement-other 6 close-paren])
@@ -648,12 +682,6 @@ conditional_entry_call
       (wisi-containing-action 3 4))
   ;
 
-conditional_quantified_expression
-  : if_expression
-  | case_expression
-  | quantified_expression
-  ;
-
 constant_opt
   : ;; empty
   | CONSTANT
@@ -1670,7 +1698,7 @@ package_specification
       (wisi-containing-action 6 7)
       (wisi-motion-action [1 4 6 8])
       (wisi-face-action [2 font-lock-function-name-face 9 font-lock-function-name-face]))
-  | PACKAGE name aspect_specification_opt IS declarative_part_opt END name_opt
+  | PACKAGE name aspect_specification_opt IS declarative_part_opt END name
     (progn
       (wisi-statement-action [1 statement-start 2 name 4 block-start 6 block-end])
       (wisi-containing-action 1 2)
@@ -1725,16 +1753,20 @@ parameter_specification_list
       (wisi-containing-action 2 3))
   ;
 
+;; ARM 4.5.7 7 allows ( conditional_expression ) instead of (( conditional_expression ))
 paren_expression
   : LEFT_PAREN expression RIGHT_PAREN
     (progn
       (wisi-statement-action [1 open-paren 3 close-paren])
       (wisi-containing-action 1 2))
- ;; ARM 4.5.7(7), ARM 4.5.8(4) allow ( conditional|quantified_expression ) instead of (( ... ))
-  | LEFT_PAREN conditional_quantified_expression RIGHT_PAREN
+  | LEFT_PAREN case_expression RIGHT_PAREN
     (progn
       (wisi-statement-action [1 open-paren 3 close-paren])
       (wisi-containing-action 1 2))
+  | LEFT_PAREN if_expression RIGHT_PAREN
+    (progn
+      (wisi-statement-action [1 open-paren 3 close-paren])
+      (wisi-containing-action 1 2))
   ;
 
 pragma
@@ -1752,8 +1784,6 @@ pragma_argument_association
 pragma_argument_association
   : IDENTIFIER EQUAL_GREATER expression
   | expression
- ;; ARM 4.5.7(7), ARM 4.5.8(4) allow ( conditional|quantified_expression ) instead of (( ... ))
-  | conditional_quantified_expression
   | IDENTIFIER TICK IDENTIFIER EQUAL_GREATER expression
   ;
 
@@ -1776,7 +1806,18 @@ primary
  ;; qualified_expression or selected_component.
     (wisi-face-action [2 font-lock-type-face] t)
  ;; | LEFT_PAREN expression RIGHT_PAREN ;; covered by aggregate
- ;; | LEFT_PAREN conditional_quantified_expression RIGHT_PAREN ; covered by aggregate
+  | LEFT_PAREN if_expression RIGHT_PAREN ;; conditional_expression
+    (progn
+      (wisi-statement-action [1 open-paren 3 close-paren])
+      (wisi-containing-action 1 2))
+  | LEFT_PAREN case_expression RIGHT_PAREN ;; conditional_expression
+    (progn
+      (wisi-statement-action [1 open-paren 3 close-paren])
+      (wisi-containing-action 1 2))
+  | LEFT_PAREN quantified_expression RIGHT_PAREN
+    (progn
+      (wisi-statement-action [1 open-paren 3 close-paren])
+      (wisi-containing-action 1 2))
   ;
 
 private_extension_declaration
_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org

Reply via email to