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

[.cmd] comments can't be on the same line of dbpf ? #2

Open
vnadot opened this issue Jun 28, 2023 · 2 comments
Open

[.cmd] comments can't be on the same line of dbpf ? #2

vnadot opened this issue Jun 28, 2023 · 2 comments

Comments

@vnadot
Copy link
Collaborator

vnadot commented Jun 28, 2023

line:

dbpf toto 8 # this is a comment

tree-sitter message:

MISSING "\n"

fix:

dbpf toto 8 
# this is a comment

In my opinion, this should be allowed

@vnadot vnadot changed the title [.cmd] comments can be on the same line of dbpf ? [.cmd] comments can't be on the same line of dbpf ? Jun 28, 2023
@minijackson
Copy link
Collaborator

So, after analyzing the iocsh parser, what happens is that # this is a comment is not interpreted as a comment.

What happens is this:

dbpf("toto", "8", "#", "this", "is", "a", "comment")

But dbpf doesn't look at arguments 3 to 7, so it gets ignored.

I'm kinda want to keep the current behavior, since you're using the parser to validate cmd files. We might want to discourage end of line comments to prevent accidents like these:

dbpf "toto" # somehow "#" is written into toto

@anjohnson
Copy link
Member

@minijackson This probably indicates a bug in iocsh, could you raise it as an issue against epics-base please? The command parser knows how many arguments most iocsh commands expect (except for those which take a variable number using argc+argv), so maybe it should be displaying a warning or an error when it sees extraneous parameters for the commands it knows about? Alternatively it could allow trailing comments, but the # character must start a new command parameter so this is not valid:

dbpf toto 8# this is not a comment

The dbpf command there would be given the value string 8# but the remaining parameters should raise that "extra parameters" warning/error first. I expect there to be discussion about whether it should be rejected as an error or just print a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants