Skip to content

Conversation

@nalundgaard
Copy link
Contributor

Problem

I merged #18 a little too soon; It has 3 issues:

  1. It doesn't handle comment lines between nested properties
  2. It doesn't handle a blank (whitespace) after = in the nested property opener like the other forms of properties.
  3. The test case was inserted in the wrong location in eini_tests module; it should have been in its own test function, and it should have had some error cases.

Solution

  1. Add support for comment lines in between nested properties.
  2. Add support for blank after = in nested property opener.
  3. Refactor and extend the tests for nested properties to cover more ground.

Known Issues

After I merged #18, I noticed this warning:

Compiled src/eini_lexer.xrl
Parse action conflict scanning symbol blank in state 51:
   Reduce to properties_nested from property_nested (rule 28 at line 97)
      vs.
   shift to state 53, adding right sisters to property_nested.
Conflict resolved in favor of shift.

It appears that the introduction of nesting has added some ambiguity to the grammar aroud the blank, and this change makes it a little worse:

Parse action conflict scanning symbol break in state 47:
   Reduce to single_value from blank (rule 44 at line 121)
      vs.
   shift to state 52, adding right sisters to blank.
Conflict resolved in favor of shift.

Parse action conflict scanning symbol blank in state 58:
   Reduce to properties_nested from property_nested (rule 30 at line 101)
      vs.
   shift to state 61, adding right sisters to property_nested.
Conflict resolved in favor of shift.

Parse action conflict scanning symbol comment in state 58:
   Reduce to properties_nested from property_nested (rule 30 at line 101)
      vs.
   shift to state 12, adding right sisters to property_nested.
Conflict resolved in favor of shift.

Now there is some ambiguity around comment as well, and this appears to cause an issue parsing INI files with a comment line at the end of a block of nested properties when another (not-nested) key follows. I don't know if we should mark this as a known issue or not, but the trigger case is in a commented unit test in eini_tests.

**Problem**

I merged #18 a little too soon; It has 3 issues:

1. It doesn't handle comment lines between nested properties
2. It doesn't handle a blank (whitespace) after `=` in the nested property opener like the other forms of properties.
3. The test case was inserted in the wrong location in `eini_tests` module; it should have been in its own test function, and it should have had some error cases.

**Solution**

1. Add support for comment lines in between nested properties.
2. Add support for blank after `=` in nested property opener.
3. Refactor and extend the tests for nested properties to cover more ground.

**Known Issues**

After I merged #18, I noticed this warning:

```
Compiled src/eini_lexer.xrl
Parse action conflict scanning symbol blank in state 51:
   Reduce to properties_nested from property_nested (rule 28 at line 97)
      vs.
   shift to state 53, adding right sisters to property_nested.
Conflict resolved in favor of shift.
```

It appears that the introduction of nesting has added some ambiguity to the grammar aroud the `blank`, and this change makes it a little worse:

```
Parse action conflict scanning symbol break in state 47:
   Reduce to single_value from blank (rule 44 at line 121)
      vs.
   shift to state 52, adding right sisters to blank.
Conflict resolved in favor of shift.

Parse action conflict scanning symbol blank in state 58:
   Reduce to properties_nested from property_nested (rule 30 at line 101)
      vs.
   shift to state 61, adding right sisters to property_nested.
Conflict resolved in favor of shift.

Parse action conflict scanning symbol comment in state 58:
   Reduce to properties_nested from property_nested (rule 30 at line 101)
      vs.
   shift to state 12, adding right sisters to property_nested.
Conflict resolved in favor of shift.
```

Now there is some ambiguity around `comment` as well, and this appears to cause an issue parsing INI files with a comment line at the end of a block of nested properties when another (not-nested) key follows. I don't know if we should mark this as a known issue or not, but the trigger case is in a commented unit test in `eini_tests`.
@nalundgaard nalundgaard requested a review from motobob May 3, 2021 23:49
@nalundgaard
Copy link
Contributor Author

@jimdigriz FYI. I looked at this issue for awhile and didn't come up with a really satisfactory refactor of the grammar to disambiguate these cases. It looks like it will be fairly rare that we encounter issues, so I am not sure how much to worry about it.

@motobob
Copy link

motobob commented May 4, 2021

tnx for foxing this up from prevolus one

@jimdigriz
Copy link
Contributor

@jimdigriz FYI. I looked at this issue for awhile and didn't come up with a really satisfactory refactor of the grammar to disambiguate these cases. It looks like it will be fairly rare that we encounter issues, so I am not sure how much to worry about it.

Thanks for looking into this, sorry for not capturing all edge cases.

For me now that I it will parse my ~/.aws/credentials configuration without me having to comment out the section every time I use eini (which seems not to be a problem for others) is great and I can live with those edge cases :)

This though is your project, so if you want me to fix up my commits (based on your work here) I am happy to do so.

@nalundgaard
Copy link
Contributor Author

This though is your project, so if you want me to fix up my commits (based on your work here) I am happy to do so.

No, that's totally alright, I'll just go ahead and merge this PR and raise a ticket for future follow up when I have a chance.

@nalundgaard nalundgaard merged commit 511a942 into master May 4, 2021
@nalundgaard nalundgaard deleted the fix_issue_18_comments branch May 4, 2021 13:30
nalundgaard added a commit to erlcloud/erlcloud that referenced this pull request May 4, 2021
* Updates eini to [1.2.9](https://github.com/erlcloud/eini/releases/tag/1.2.9) (see support nested properties, erlcloud/eini#19).
* Updates `rebar.lock` format to 1.2.0 from the latest rebar3 versions.
nalundgaard added a commit to erlcloud/erlcloud that referenced this pull request May 4, 2021
* Updates eini to [1.2.9](https://github.com/erlcloud/eini/releases/tag/1.2.9) (see support nested properties, erlcloud/eini#19).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants