Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiline comments #77

Closed
msaarna opened this issue Sep 8, 2020 · 13 comments
Closed

multiline comments #77

msaarna opened this issue Sep 8, 2020 · 13 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@msaarna
Copy link
Member

msaarna commented Sep 8, 2020

This is an enhancement request for C style /* */ comments. I have the code, which I'll be pushing to master shortly.

Some suggested documentation comments follow...

Comments

Dasm has two different comment styles available, traditional assembler single-line ";" comments, and C-style "/* */" multiline comments.

Multiline comments make it easy to turn large blocks of code or text into comments. The "/" characters indicate the start of a comment block, and the "/" characters indicate the end of a block.

Valid multiline comment examples...

/* This single line comment is valid */

lda #1 /* And this comment is valid too */

/* And so is this
Multiline comment */

Inserting comments before a label or opcode isn't supported in dasm.

Invalid multiline comment examples...

/* the opcode to the right will be ignored */ lda #1

/* and so is the opcode
that follows this block
*/ lda #1

@msaarna msaarna self-assigned this Sep 8, 2020
@msaarna msaarna added the enhancement New feature or request label Sep 8, 2020
@msaarna
Copy link
Member Author

msaarna commented Sep 8, 2020

@andrew-davie andrew-davie self-assigned this Sep 8, 2020
@thrust26
Copy link
Member

thrust26 commented Sep 8, 2020

What happens with multiline comments inside multiline comments?

E.g. /* abc /* 123 */ def */

Does it assemble or not?

@andrew-davie
Copy link
Member

Can you please test this with directives inside the comment block?
Something like

 /* IF 0
*/
  echo "hello world"

@msaarna
Copy link
Member Author

msaarna commented Sep 8, 2020

@thrust26, they're not recursive. (neither are the same multiline style in C, java, ...) In your particular example, the entire line would be a comment. (see the the "doc" text above inserting comments prior to label or opcode.) If it stretched across multiple lines, the first */ encountered would be the terminator, the second an unknown opcode or label, depending on it's position.

@andrew-davie, the functionality is part of the pre-interpreting cleanup, so it should work the same for everything. It just turns the block into a series of traditional single-line comments. Here's the list from your request...

------ FILE scratch.asm LEVEL 1 PASS 1
1 0000 ???? ;/* IF 0
2 0000 ???? ;*/
hello world
3 0000 ???? echo "hello world"
4 0000 ????

@andrew-davie
Copy link
Member

Perfect, thanks.
The revised documentation will be up in about 5 minutes.

@andrew-davie
Copy link
Member

Documentation updated ef0f21d

@andrew-davie
Copy link
Member

A missing close-comment is not flagged by dasm.
That is, if you start a comment, then all the remaining code is not assembled.
It would be nice to flag this as an error.

@andrew-davie
Copy link
Member

An isolated */ at the beginning of a line is interpreted as a label (!)
If there is whitespace before it, then it is reported as an error, as expected.

@msaarna
Copy link
Member Author

msaarna commented Sep 8, 2020

I've updated master. Both cases will be flagged with a specific error now.

@andrew-davie
Copy link
Member

TY. Tested and confirmed working on my use-cases.

@andrew-davie
Copy link
Member

In the case where anything on a line after */ is ignored, this is a pretty non-obvious silent failure.
Could anything after */ on a line be flagged as an error, or at the very least a warning?
For example, I don't believe the following code should compile...

/*
 */ this is an error

@msaarna
Copy link
Member Author

msaarna commented Sep 10, 2020

Rather than doing a quarter of the work and alert for all failures, I updated the code to handle multi-line comments exactly like C. They can now proceed labels and ops, or even be between an op and an op argument, multiple comments per line, whatever. They still get added to the end-line comment in the list file, but otherwise they're completely invisible to the parser now, wherever they are.

Sorry to make you revise the doc, but the comments about restrictions can be removed there.

Heads up that I also added a test case. I tried adding it for visibility here, but the software here mangled it, despite the code tag.

@dionoid dionoid added this to the 2.20.14 milestone Sep 12, 2020
@msaarna
Copy link
Member Author

msaarna commented Sep 12, 2020

Docs have be kindly updated by Andrew. Closing off this issue.

@msaarna msaarna closed this as completed Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants