pantoniou / libfyaml

Fully feature complete YAML parser and emitter, supporting the latest YAML spec and passing the full YAML testsuite.
MIT License
241 stars 74 forks source link

dump_scan_token prints KEY twice #65

Open geert56 opened 1 year ago

geert56 commented 1 year ago

I assume that dump_scan_token in fy-tool.c in case of FYTT_VALUE should print VALUE or something like that, but not KEY.

geert56 commented 1 year ago

And I just learned that also BLOCK_ENTRY is printed both in case of FYTT_BLOCK_ENTRY and FYTT_FLOW_ENTRY. I assume the latter must print FLOW_ENTRY?

pantoniou commented 1 year ago

Token scan mode is just a debugging aid. Are you trying to create a new YAML parser or something?

The interface is completely private and the documentation of the methods clearly state that this is just for YAML implementers.

geert56 commented 1 year ago

I am just pointing out what I think to be minor errors in the code. They probably would not affect regular use. But I am interested to use fy-tool to generate the tokens output and in that case the indicated errors do cause the wrong output.

pantoniou commented 1 year ago

If you can share the input that causes this behavior we can have more concrete data to talk about.

geert56 commented 1 year ago

In master libfyaml/src/tool/fy-tool.c:

    case FYTT_BLOCK_ENTRY:
        if (colorize)
            fputs(A_BRIGHT_CYAN, stdout);
        printf("BLOCK_ENTRY");
        break;
    case FYTT_FLOW_ENTRY:
        if (colorize)
            fputs(A_BRIGHT_YELLOW, stdout);
        printf("BLOCK_ENTRY");
pantoniou commented 1 year ago

Oh, yeah, that's a bug - file a PR

As I said this is just a debugging aid, never been used for anything besides that until now.

geert56 commented 1 year ago

Same file fy-tool.c:

    case FYTT_KEY:
        if (colorize)
            fputs(A_BRIGHT_YELLOW, stdout);
        printf("KEY");
        break;
    case FYTT_VALUE:
        if (colorize)
            fputs(A_BRIGHT_YELLOW, stdout);
        printf("KEY");
geert56 commented 1 year ago

fy-tool is a great tool for YAML analyzers and processors. Useful to use in some AI pipeline to feed a model with YAML code.

pantoniou commented 1 year ago

Sure, but the scan token interface is completely non-standard.

The event interface is probably what you need.

On Tue, Feb 7, 2023 at 4:50 PM Geert Janssen @.***> wrote:

fy-tool is a great tool for YAML analyzers and processors. Useful to use in some AI pipeline to feed a model with YAML code.

— Reply to this email directly, view it on GitHub https://github.com/pantoniou/libfyaml/issues/65#issuecomment-1420901125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQGJWWBN36KVEB6KAAMKFLWWJOKVANCNFSM6AAAAAATMRS3P4 . You are receiving this because you commented.Message ID: @.***>

geert56 commented 1 year ago

Am I allowed to create a pull request? I am trying to push my issue65 branch but am getting permission denied.

pantoniou commented 1 year ago

You need to fork and create the PR from your fork.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

On Tue, Feb 7, 2023 at 6:16 PM Geert Janssen @.***> wrote:

Am I allowed to create a pull request? I am trying to push my issue65 branch but am getting permission denied.

— Reply to this email directly, view it on GitHub https://github.com/pantoniou/libfyaml/issues/65#issuecomment-1421040120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQGJWT2WTOFKCM2X4LB4YTWWJYNLANCNFSM6AAAAAATMRS3P4 . You are receiving this because you commented.Message ID: @.***>