boschresearch / blech

Blech is a language for developing reactive, real-time critical embedded software.
Apache License 2.0
72 stars 5 forks source link

Unexpected end of file after ///-comment #37

Closed 0-T-K closed 3 years ago

0-T-K commented 3 years ago

If a ///-comment is not followed by any code, the compiler throws an "unexpected end of file." error.

Example code:

@[EntryPoint] activity Main () () await true end

/// Test // bla

schorg commented 3 years ago

This is not a bug it is a feature. It also does not throw an error but reports a syntax error.

A line-doc comment must be followed by a declaration that is documented by this line doc comment. This declaration is missing.

It is similar to an incomplete declaration.

module
activity A () ()
    await true
end

function f

This also reports an unexpected end of file. This syntax error message is the price to pay when adding special comments to the abstract syntax tree. Allowing a doc comment at the end of a file leads to serious shift-reduce conflicts that cannot be resolved.

The only thing that can be improved is the error message from the parser. See the discussion Improve syntax error message #40