mezoni
mezoni

Reputation: 11210

Which style of multiline comments used on Dart?

Which style of multiline comments used on Dart?

I know the C-style of the multiline comments. This style does not allow multiline comments inside multiline comments (nested comments).

That is the 'C' style comments end at the first */ encountered in multiline comments.

Examples:

Vaild C-style comment:

/*
*/

Not valid C-style comment:

/*
/**/
*/

In Dart both styles are valid but as I know in most popular languages ​​used only the C-style comments.

Here is my question.

From whence this style in Dart language? From a historical point of view and practical.

P.S.

I am writing PEG parser for Dart and was surprised when I found it in the grammar. This rule does not allow in my parser auto recognize multilne comment as terminal because it recursive call himself.

MULTI_LINE_COMMENT <- '/*' (MULTI_LINE_COMMENT / !'*/' .)* '*/' ;

Also how this multiline comment can be described in Bison/Flex terminology?

This question arrives because in PEG parser terminology the comments are part of white spaces. And the white spaces in most cases can be assumed as terminals because they does not change behaviour (they does not branch and are not recursive by human logic, i.e produced directly into tokens by lexical scaners).

I know that in PEG parsers there is no division on terminals and not-terminals but for better error reporting some euristic analysis of grammar rules never prevents

Upvotes: 2

Views: 276

Answers (1)

munificent
munificent

Reputation: 12364

From whence this style in Dart language?

I believe they added this because it makes it easier to comment out large blocks of code which may already contain block comments. Most other grammatical constructs nest, so it always seemed strange that C-style block comments did not to me.

I think C originally worked that way because it made it easier to lex on old PDP-11s with almost no memory. We don't have that limitation anymore, so we can have a more user-friendly comment syntax.

Upvotes: 2

Related Questions