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

Comments aren't parsed correctly #150

Open
unmanned-player opened this issue Nov 30, 2020 · 2 comments
Open

Comments aren't parsed correctly #150

unmanned-player opened this issue Nov 30, 2020 · 2 comments

Comments

@unmanned-player
Copy link
Contributor

unmanned-player commented Nov 30, 2020

When a comment appears as part of list it fails to parse correctly. See an example below:

targets = {
    "Life", # Comment
    "Universe",
    "Everything"
}

In this list, a comment appears along with one of the list items and fails with the error:

simple.conf:1: unexpected token 'Comment'

The lexer suggests,

 /*
  * handle one-line comments
  *
  * Note: Comments with lots of leading #### or //// are fully
  *       consumed and are not included in CFGT_COMMENT yylval
  */
"#"{1,}.*   return qstr(cfg, '#', CFGT_COMMENT);
"/"{2,}.*   return qstr(cfg, '/', CFGT_COMMENT);

So I added extra '#' to see if this goes away. But it didn't.

Sometimes in our usage, we do comment out a few configuration items or leave a comment next items. The new parser in 3.3 (master) seems to be also collecting comments for some reason.

Note, we were using libConfuse version 3.0 and were planning to move to 3.3 owing to some memory leak fixes. But there seems to be some feature about CFGF_COMMENTS for which I can't seem to find proper documentation on to understand the rationale behind it.

What is the right way to comment out or put comments inside of lists?

@troglobit
Copy link
Collaborator

This is not good. Definite bug in the lexer, because just about any type of C/C++/UNIX style comment should work ...

@wvxvw
Copy link

wvxvw commented Apr 29, 2022

Hi, to add to this, comments of the kind:

foo /* comment */ = bar

also don't work. In fact, it looks like the parser believes that */ must terminate the line (if my understanding of this part is correct: https://github.com/libconfuse/libconfuse/blob/master/src/lexer.l#L419

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