swp-uebersetzerbau-ss13 / common

Shared files between teams.
1 stars 0 forks source link

Meaning of # in the add.prog - example #18

Closed flofreud closed 11 years ago

flofreud commented 11 years ago

What should be the meaning of # in the add.prog - example? https://github.com/swp-uebersetzerbau-ss13/common/blob/master/examples/m1/add.prog

From context I would infer that it should be a line-comment but we don't have a comment-definition / handling defined yet.

  1. Should this be a line comment?
  2. Is there a requirement that we should add the comment-functionality to the specification?
SWP-Comp-Deathk commented 11 years ago
  1. Yes The # ist a Comment
  2. No because the grammar has no specification for comments.

Danny

flofreud commented 11 years ago

Out of the situation that comments are standard for programming languages and the "have to be compilable" MS1 examples use them, here a

Proposal: For convenience the language will be extended by a simple line comment construct. Comments are helpful for the description of expected behavior for source language code. Block comments would be nice to have but not essential.

Format: The line comment starts with a '#' and ends with the next '\n'. Lexer-semantic: Normally a lexer would ignore characters belonging to tokens entirely. Contrary to that I and @Tkrauss propose to let the lexer create a token for the comment. This token will be normally ignored by the parser but can be used for the visualization of the lexer work.

If this proposal is accepted I volanteer for adding the comment to the TokenType.

damlabeyaz commented 11 years ago

I hardly understand why it should be visualized, that the lexer ignores comments. At most, we can log its work where we do not need a special token. As long as there is no really important and convincing reason to create a special token (work can also be logged, isn't this convincing?), I would not accept.

damlabeyaz commented 11 years ago

After a discussion with @flofreud I accept this proposal. The parser can skip the comment tokens but for the visualization, comment tokens are very helpful.