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

happy emits code using -XCPP even in the absence of --ghc #263

Closed
sgraf812 opened this issue Jan 22, 2024 · 3 comments
Closed

happy emits code using -XCPP even in the absence of --ghc #263

sgraf812 opened this issue Jan 22, 2024 · 3 comments

Comments

@sgraf812
Copy link
Collaborator

I'm seeing that happy generates Haskell files such as

happySpecReduce_2 nt fn (j::FAST_INT) tk _ CONS(_,sts@(CONS(st@HAPPYSTATE(action),_))) (v1`HappyStk`v2`HappyStk`stk')
     = let r = fn v1 v2 in
       happySeq r (GOTO(action) nt j tk st sts (r `HappyStk` stk'))

since the unreleased 2.0 version, I think.

While I understand that it's far easier to lean on GHC's CPP extension to generate parsers, doing so kind of implies --ghc.

If we want to go that route, can't we go all the way also get rid of the non---ghc mode of happy?

@int-index
Copy link
Collaborator

The fact that CPP is emitted at all (with or without --ghc) creates issues. For example, happy can't be used as a preprocessor with -pgmF.

So, ideally, there should be a mode to emit parsing code with all CPP conditionals resolved in some reasonable way.

@sgraf812
Copy link
Collaborator Author

sgraf812 commented Jan 22, 2024

Hmm. Perhaps that mode isn't the good old "generate Haskell code via String" backend? Unless...

I'm currently working on happy to implement a proper error recovery mode and wonder if all these different modes are necessary, because they are painful to maintain.
GHC only uses -agc. I don't see any reason to pass different flags. Well, perhaps omitting -a to get a recursive ascent parser with explicit stack, but that reportedly leads to much larger parsers; plus, there's also a recursive ascent-descent mode available in https://github.com/knothed/happy-rad.

So if we are going to have breaking changes anyway, perhaps we can be more ambitious?

@sgraf812
Copy link
Collaborator Author

No longer an issue after #278.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants