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

Strip tilde prefixes from WordTildePrefix #164

Merged
merged 23 commits into from
Jun 5, 2023
Merged

Strip tilde prefixes from WordTildePrefix #164

merged 23 commits into from
Jun 5, 2023

Conversation

Niols
Copy link
Member

@Niols Niols commented May 8, 2023

fix #163

In the example (taken from the tests) X=~kn:~/bin:~darkvador/secret as an assignment word, Morbig parses the tilde prefixes as WordTildePrefix "~kn", WordTildePrefix "~" and WordTildePrefix "~darkvador". Since ~ is already contained as an information in WordTildePrefix, then it should be stripped off the carried string. This PR implements that.

@Niols Niols self-assigned this May 8, 2023
@Niols
Copy link
Member Author

Niols commented May 8, 2023

While investigating this, I actually found a few more bugs, namely:

  1. In the example above, X=~kn:~/bin:~darkvador/secret (as an assignment word), Morbig actually forgets both about the / and the : characters. To some extent, they can be guessed, but this is not very clean.

  2. In the example Y=~kn:/bonjour:~/bonsoir:and/this/one (as an assignment word), Morbig considers that there is a WordTildePrefix "" before /bonjour and a WordTildePrefix "and" before /this/one.

  3. In the example Z=/bonjour:~kn:~/bonsoir:and/this/one (as an assignment word), Morbig does nothing while it should process and find the tilde prefixes ~kn and ~ before /bonsoir.

88d6a2c introduces the two additional tests for Y and Z and the fixes the expectation file that goes with them. Of course, at this point, tests don't pass. The coming commits should fix that. I also expect that the expectation file might change a bit, but only to split some WordLiteral into several ones. We shall see.

@Niols Niols force-pushed the tilde-prefixes branch from 5632c2e to cda079a Compare May 9, 2023 00:36
@Niols
Copy link
Member Author

Niols commented May 9, 2023

The last commit adds two more test cases for words with tildes that are not assignment words. This is to check that Morbig is not overzealous in those cases and that it indeed does not find tilde prefixes in the middle of a colon-separated word.

@Niols
Copy link
Member Author

Niols commented May 9, 2023

Alright, I think this is starting to look pretty good. However, I am quite puzzled by the way Morbig recognizes assignment words. In particular, Morbig recognizes assignment words on the right-hand side of a command name and I don't think this is right, but I have to read the standard some more before deciding what to think. That is not what dash does, in any case. I added some test cases but I don't think changing Morbig's behaviour is within the scope of this PR. I will open an issue to track this.

@Niols
Copy link
Member Author

Niols commented May 10, 2023

Had to merge main into this to resolve the conflicts with #167. I suggest squashing this PR.

@Niols Niols requested a review from yurug May 10, 2023 17:25
@Niols
Copy link
Member Author

Niols commented May 12, 2023

@yurug Merged #169 into main and main into this PR, so now we have our fancy test suite running here. This PR is ready for review.

src/tildePrefix.ml Outdated Show resolved Hide resolved
src/tildePrefix.ml Outdated Show resolved Hide resolved
src/tildePrefix.ml Outdated Show resolved Hide resolved
src/tildePrefix.ml Outdated Show resolved Hide resolved
@yurug
Copy link
Contributor

yurug commented May 23, 2023

LGTM. I only add minor comments.

@Niols
Copy link
Member Author

Niols commented May 24, 2023

The CI problem comes from the Archlinux image not managing to fetch jq. I don't think it is blocking so I will leave it at that. @yurug WDYT of the new version?

@yurug
Copy link
Contributor

yurug commented Jun 5, 2023

LGTM!

@Niols Niols merged commit a50e6bf into main Jun 5, 2023
@Niols Niols deleted the tilde-prefixes branch June 5, 2023 12:50
~name:"List.(bd @ [tl] = id)"
(list int)
(fun l ->
assume (List.compare_length_with l 2 >= 0);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size 1 here would be sufficient, actually.

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.

Tilde prefixes are kept in the CST
2 participants