Skip to content

C++ backend: Parser.H declares pX(const char*) but implementation defines psX(const char*) #524

Closed

Description

@TheGhoul21

I noticed a mismatch between the function declarations in Parser.H and their definitions in the generated Bison file.

In CFtoBisonC.hs (lines 212, 217), two entry points are generated for each category:

Program* pProgram(FILE *inp);        // parse from file
Program* psProgram(const char *str); // parse from string ("s" for string)

However, in STL.hs (lines 188-189) the header declarations are:

  mkFuncs s =
    [ identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(FILE *inp);"
    , identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(const char *str);"
    ]

This generates:

  Program* pProgram(FILE *inp);
  Program* pProgram(const char *str);  // should be psProgram

Similarly, NoSTL.hs only declares the FILE* version and is missing the const char* declaration entirely.

Question: Is this a bug, or am I misunderstanding something? If it's a bug, I'm happy to submit a PR with the fix.

Activity

  1. andreasabel commented on Jan 25, 2026

    @andreasabel
    Member

    Referenced code:

    --This generates a parser method for each entry point.
    parseMethod :: ParserMode -> CF -> Cat -> String
    parseMethod mode cf cat = unlines $ concat
    [ [ unwords [ "/* Entrypoint: parse", dat, "from file. */" ]
    , dat ++ " p" ++ parser ++ "(FILE *inp)"
    ]
    , body False
    , [ ""
    , unwords [ "/* Entrypoint: parse", dat, "from string. */" ]
    , dat ++ " ps" ++ parser ++ "(const char *str)"
    ]
    , body True
    ]

    mkFuncs s =
    [ identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(FILE *inp);"
    , identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(const char *str);"
    ]

    mkFunc s = identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(FILE *inp);"

  2. TheGhoul21 commented on Jan 26, 2026

    @TheGhoul21
    Author

    thanks for the referenced code. I should have put those in the first place, sorry about that.
    But is this a confirmation about the problem? Should I go ahead and try a PR?

  3. added
    regression in 2.9.2
    on Jan 26, 2026
  4. added this to the 2.9.6.2 milestone on Jan 26, 2026
  5. added 2 commits that reference this issue on Jan 26, 2026
    d5af1ca
    f780064
  6. andreasabel commented on Jan 26, 2026

    @andreasabel
    Member

    I put a fix up at #527.

    One question that should be answered is why the testsuite did not catch this regression. How do I make the C++ compiler check strictly that declarations in .H and .C files match?

  7. added
    entrypoints
    on Jan 26, 2026
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

    C++entrypointsregression in 2.9.2

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions