haskell / happy

The Happy parser generator for Haskell
Other
276 stars 85 forks source link

Create Grammar package #205

Closed knothed closed 2 years ago

knothed commented 2 years ago

Create a Grammar package just containing the Grammar datatype.

int-index commented 2 years ago

LGTM overall. There are a few unnecessary formatting changes, I suggest to undo them by applying this patch

diff --git a/packages/grammar/src/Happy/Grammar/Grammar.lhs b/packages/grammar/src/Happy/Grammar/Grammar.lhs
index bc0822c..594034e 100644
--- a/packages/grammar/src/Happy/Grammar/Grammar.lhs
+++ b/packages/grammar/src/Happy/Grammar/Grammar.lhs
@@ -25,7 +25,7 @@ The Grammar data type.

 > data Production
 >       = Production Name [Name] (String,[Int]) Priority
->       deriving (Show)
+>       deriving Show

 > data Grammar
 >       = Grammar {
diff --git a/src/LALR.lhs b/src/LALR.lhs
index b1d746e..a6e5473 100644
--- a/src/LALR.lhs
+++ b/src/LALR.lhs
@@ -6,7 +6,7 @@ Generation of LALR parsing tables.
 -----------------------------------------------------------------------------

 > module LALR
->       (ActionTable, GotoTable, 
+>       (ActionTable, GotoTable,
 >        genActionTable, genGotoTable, genLR0items, precalcClosure0,
 >        propLookaheads, calcLookaheads, mergeLookaheadInfo, countConflicts,
 >        Lr0Item(..), Lr1Item(..), ItemSetWithGotos, LRAction(..), Goto(..))
@@ -53,16 +53,12 @@ This means rule $a$, with dot at $b$ (all starting at 0)
 >               | LR'Fail               -- :-(
 >               | LR'MustFail           -- :-(
 >               | LR'Multiple [LRAction] LRAction       -- conflict
->       deriving (Eq, Show)
+>       deriving (Eq,Show)

-> type ActionTable
->      = Array Int{-state-} (Array Int{-terminal#-} LRAction)
-> type GotoTable
->      = Array Int{-state-} (Array Int{-nonterminal #-} Goto)
-> data Goto
->      = Goto Int
->      | NoGoto
->      deriving(Eq, Show)
+> type ActionTable = Array Int{-state-} (Array Int{-terminal#-} LRAction)
+> type GotoTable = Array Int{-state-} (Array Int{-nonterminal #-} Goto)
+> data Goto = Goto Int | NoGoto
+>       deriving (Eq, Show)

 -----------------------------------------------------------------------------
 Generating the closure of a set of LR(0) items

This way git diff master --color-moved=blocks -w can detect more changes as moved blocks rather than removed/added code.

Ericson2314 commented 2 years ago

We can always do the inverse of that patch as follow up commit/PR :)

int-index commented 2 years ago

bisecting is easier when commits do as little as possible.

knothed commented 2 years ago

Okay done. :)

int-index commented 2 years ago

The CI fails with

cabal: Could not resolve dependencies:
[__0] trying: happy-1.21.0 (user goal)
[__1] unknown package: happy-grammar (dependency of happy)
[__1] fail (backjumping, conflict set: happy, happy-grammar)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: happy, happy-grammar

even though I can build locally with cabal build all -f -bootstrap.

@Ericson2314 do you know what needs to be done about this? I don’t really understand the current CI config.

knothed commented 2 years ago

I updated the haskell-ci config manually to include the grammar package. It should work now (but needs approval from a maintainer to run).

This should be done in an automated way, somehow haskell-ci github doesn't work for me, I'm on a Mac.

int-index commented 2 years ago

Thanks!