Skip to content

Generating Lexer/Parser file in a specific encoding #232

Open

Description

@lkluc

I am migrating a project to a CI/CD pipeline for which there is a step which ensures that all .fs files are UTF-8 with BOM.

I have some unit tests which are generated by FsLexYacc and are not adhering to this CI/CD specification.

I would need to have FsLexYacc generate files enforcing a specific encoding, which is, in my case UTF-8 with BOM.

I tried to look in the available command line options of the generators, and it seems the options are regarding the input, not the output.

Could we add an option to specify an output encoding (or code page if we align with the current input options) ?

Thanks !

Activity

  1. baronfel commented on May 16, 2025

    @baronfel
    Collaborator

    This is a great suggestion - would you be interested in implementing it yourself? It looks like it should be a matter of

    • adding a new CLI option (maybe --output-codepage) similar to the existing one here and here and adding matching mutable defaults for those options
    • adding new configuration to the Writer types for fslex and fsyacc to actually use those passed-in values
  2. lkluc commented on May 23, 2025

    @lkluc
    Author

    Hello @baronfel , good news, I followed your advice and made the fix.

    I end up implementing it with a --out-bom boolean command line switch available on both programs, fslex and flyacc, because specifying only the codepage (number 65001 for in this case, UTF-8) would not have enable the user to specify with or without BOM, I'm not an I18n expert but it seems the codepage number are being the same in both cases.

    So I kept UTF-8 encoding only for now, no other weird ISO-something encoding.

    I have created a feature/output-encoding.0 branch on my computer, however when I tried to push it, it seems I'm required to have some permissions granted to me? Nor is it some configuration required on my side?

    remote: Permission to fsprojects/FsLexYacc.git denied to lkluc.
    fatal: unable to access 'https://github.com/fsprojects/FsLexYacc.git/': The requested URL returned error: 403
    

    Thanks !

  3. baronfel commented on May 23, 2025

    @baronfel
    Collaborator

    Good to hear! You'll have to make a fork of this repository, then push your branch to your fork and make a pull request here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions