Skip to content

Commit

Permalink
[ fix #356 ] trust the user's "layout toplevel" declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Jun 5, 2021
1 parent 3265143 commit 78fb571
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Andreas Abel <andreas.abel@gu.se> (unreleased)
## Bug fixes and small improvements

* Haskell-GADT: generated code is warning free [#346]
* Haskell: fixes in layout preprocessor [#343,#344,#345,#352,#353,#356]
* Haskell: fixes in layout preprocessor [#343,#344,#345,#352,#353]
* Haskell: print `[Char]` correctly, removed method `prtList` [#359]
* Haskell: added missing import [#368], regression introduced in 2.9.1 by [#331]
* C: fixed a space leak when parsing from a string in memory [#347]
Expand Down
2 changes: 1 addition & 1 deletion source/src/BNFC/Backend/Haskell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ testfile opts cf = unlines $ concat $
| lay = unwords [ "resolveLayout", show useTopLevelLayout, "$ myLexer", atom]
| True = unwords [ "myLexer", atom]
(hasTopLevelLayout, layoutKeywords, _) = layoutPragmas cf
useTopLevelLayout = isJust hasTopLevelLayout && isList topType
useTopLevelLayout = isJust hasTopLevelLayout


runStd xml myLLexer = unlines $ concat
Expand Down
1 change: 0 additions & 1 deletion testing/regression-tests/194_layout/test.cf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ TySig. Decl ::= Ident ":" Ident ;
separator Decl ";" ;

layout "where", "private" ;
layout toplevel ; -- this should have no effect since the entrypoint is not a list

comment "--" ;
comment "{-" "-}" ;
1 change: 1 addition & 0 deletions testing/regression-tests/356_LayoutSnocList/bad01.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 2 3
3 changes: 3 additions & 0 deletions testing/regression-tests/356_LayoutSnocList/good01.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1
2
3
7 changes: 7 additions & 0 deletions testing/regression-tests/356_LayoutSnocList/test.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Andreas, 2021-06-05, issue #356.
-- Layout should also with snoc-lists, in particular top-level layout.

layout toplevel;

Nil. Ints ::= ;
Snoc. Ints ::= Ints Integer ";" ;
5 changes: 4 additions & 1 deletion testing/src/ParameterizedTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ currentRegressionTest = makeTestSuite "Current parameterized test" $
-- | Layout currently only works for Haskell (even Agda) and Haskell/GADT.
layoutTest :: Test
layoutTest = makeTestSuite "Layout parsing test" $ concat
[ map (`makeTestCase` ("regression-tests" </> "194_layout")) $
[ map (`makeTestCase` ("regression-tests" </> "356_LayoutSnocList")) $
[ haskellParameters
]
, map (`makeTestCase` ("regression-tests" </> "194_layout")) $
[ haskellGADTParameters
, haskellAgdaParameters
]
Expand Down

0 comments on commit 78fb571

Please sign in to comment.