AdaCore / ada-spark-rfcs

Platform to submit RFCs for the Ada & SPARK languages
63 stars 28 forks source link

Implicit ';' when known form context #54

Closed jquorning closed 3 years ago

jquorning commented 4 years ago

Proposal

Make semicolon (';') optional in cases when statement end is known by program text context. Lets make semicolon optional when not needed anyway..

Example

procedure semicolon is
   i, n : natural
   c : constant positive := 123

   function func (p : integer) return integer
   function func (p : integer) return integer is
   begin
       return p + 5 + c
   end

begin
   null                  -- comment
   n := 3  ; n := c + 5 -- semicolon needed
   i := func (n)
end semicolon

Parser outputs

Outputs from GNAT compiler:

semicolon.adb:2:17: missing ";"
semicolon.adb:3:31: missing ";"
semicolon.adb:5:45: missing ";"
semicolon.adb:8:22: missing ";"
semicolon.adb:9:06: missing ";"
semicolon.adb:12:08: missing ";"
semicolon.adb:13:24: missing ";"
semicolon.adb:14:17: missing ";"
semicolon.adb:15:14: missing ";"

This indicates that the semicolon is redundant in many if not most cases.

Rationale

The semicolon (';') was introduced to help the parser.

Implementation

This proposal is expected to be easy to implement in the compiler parser.

raph-amiard commented 4 years ago

Hi @jquorning , thank you for your interest!

However, you should supply more information on your issues, so that we can at least understand what you are proposing. Could you please fill the description with a small explanation of the problem and potential solution ?

Thanks in advance.

jquorning commented 4 years ago

@raph-amiard , Thank You for your suggestions. I hope the newest brushup will clarify the proposal.. :-)

raph-amiard commented 4 years ago

@jquorning much better indeed! Thanks 🙂

raph-amiard commented 3 years ago

Hi @jquorning,

This looks like this is out of the scope of what we want to accomplish, and more in the scope of a more in-depth syntax revisit of Ada, so we'll be closing this.

Kind regards