parser icon indicating copy to clipboard operation
parser copied to clipboard

Update parser as per latest changes in nom

Open subhojit777 opened this issue 7 years ago • 9 comments

subhojit777 avatar Sep 21 '18 04:09 subhojit777

Thanks for the PR!

Do you have an idea why tests are failing?

Hywan avatar Sep 21 '18 07:09 Hywan

I will take a look. I did cargo build, and I came to know to know that InputTake and InputTakeAtPosition are not implemented. I will look into the tests.

subhojit777 avatar Sep 21 '18 09:09 subhojit777

I looked into the remaining failing tests. One of them is case_exclude_empty_set(). I found that it is failing because it uses the InputTakeAtPosition and FindToken implementations of &[u8] which is provided by the nom framework.

The test output:

Diff < left / right > :
 
<Err(
<    Incomplete(
<        Size(
<            1
<        )
>Ok(
>    (
>        [],
>        [
>            102,
>            101,
>            100,
>            97,
>            98,
>            99
>        ]
     )
 )

Do you think that they need to be implemented differently inside the parser library? @Hywan

subhojit777 avatar Oct 09 '18 03:10 subhojit777

    fn case_exclude_empty_set() {
        named!(
            test,
            exclude!(
                is_a!("abcdef"),
                alt!(
                    tag!("abc")
                  | tag!("ace")
                )
            )
        );

        assert_eq!(test(&b"fedabc"[..]), Ok((&b""[..], &b"fedabc"[..])));
    }

is_a!("abcdef") uses find_token() which returns bool. But split_at_position1() does Some() pattern match-ing. This is weird. I think I am missing something here. Any idea?

subhojit777 avatar Oct 09 '18 03:10 subhojit777

Please, give me some days to look at this. I don't time right now, hope to get free time in few days :-). Thanks for your patience!

Hywan avatar Oct 09 '18 08:10 Hywan

Meanwhile I can do more investigation.

https://github.com/tagua-vm/parser/pull/132#issuecomment-428047935 - I am wrong in this comment. It is alright there. The find() inside split_at_position1() expects the Fn to return a bool

But I am confused here because in every iteration it is true, still it is executing the None arm.

subhojit777 avatar Oct 10 '18 03:10 subhojit777

Working on this right now.

Hywan avatar Nov 14 '18 13:11 Hywan

@Hywan Did you check this?

subhojit777 avatar Dec 05 '18 03:12 subhojit777

Yes, and I have similar issue. I've paused my patch for some weeks because of other projects. I'm planning to switch back to Tagua VM very soon.

Hywan avatar Dec 05 '18 09:12 Hywan