BNFC 2.9.6.1 → 2.9.6.2
raw patch · 10 files changed
+70/−38 lines, 10 filesdep −processdep −transformersPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependencies removed: process, transformers
API changes (from Hackage documentation)
+ BNFC.Backend.CPP.STL: mkEntryFuncs :: Cat -> [String]
Files
- BNFC.cabal +3/−12
- CHANGELOG.md +17/−1
- src/BNFC/Backend/C/CFtoBisonC.hs +36/−13
- src/BNFC/Backend/CPP/NoSTL.hs +2/−3
- src/BNFC/Backend/CPP/STL.hs +5/−3
- src/BNFC/Backend/Txt2Tag.hs +3/−3
- stack-9.10.yaml +1/−1
- stack-9.12.yaml +1/−1
- stack-9.8.yaml +1/−1
- test/BNFC/OptionsSpec.hs +1/−0
BNFC.cabal view
@@ -1,5 +1,5 @@ Name: BNFC-Version: 2.9.6.1+Version: 2.9.6.2 cabal-version: 2.0 -- >=2.0 for build-tool-depends: hspec-discover -- Andreas, 2022-12-16, issue #429:@@ -33,7 +33,7 @@ -- Support range when build with cabal tested-with: GHC == 9.12.2- GHC == 9.10.2+ GHC == 9.10.3 GHC == 9.8.4 GHC == 9.6.7 GHC == 9.4.8@@ -108,11 +108,8 @@ , filepath , mtl >= 2.2.1 , pretty >= 1.1 && < 1.2- , process , string-qq , time- , transformers- -- for Control.Monad.IO.Class, which is in base >= 4.9 but not below build-tool-depends: alex:alex, happy:happy@@ -290,18 +287,12 @@ base, mtl, directory,- array,- process, filepath, pretty, hspec, QuickCheck >= 2.5, HUnit,- temporary,- containers,- deepseq,- string-qq,- time+ temporary build-tool-depends: alex:alex, happy:happy,
CHANGELOG.md view
@@ -1,4 +1,20 @@-# Unreleased+# 2.9.6.2++Andreas Abel <andreas.abel@gu.se>, January 2026++* C: fix type of `lex_destroy`+ [[#513](https://github.com/BNFC/bnfc/issues/513)]+* C++: fixing 2 regressions introduced in 2.9.2+ - `parse_error` exception not thrown+ [[#493](https://github.com/BNFC/bnfc/issues/493)]+ - entrypoint for file and string parsing should have same name (overloaded function)+ [[#524](https://github.com/BNFC/bnfc/issues/524)]+* txt2tags: remove extra closing bracket in `String` literal description in `Doc.txt`+ [[#511](https://github.com/BNFC/bnfc/issues/511)]++Builds with GHC versions:+* with `cabal`, GHC 8.0 - 9.12+* with `stack`, GHC 8.4 - 9.12 # 2.9.6.1
src/BNFC/Backend/C/CFtoBisonC.hs view
@@ -118,6 +118,7 @@ -- Fixing regression introduced in 2.9.2. , when (stlParser mode) [ "#include <algorithm> /* for std::reverse */" -- mandatory e.g. with GNU C++ 11+ , "#include \"" ++ ("ParserError" <.> h) ++ "\"" -- for throwing parser_error in C++ ] , [ "#include <stdio.h>" , "#include <stdlib.h>"@@ -137,7 +138,7 @@ , "extern YY_BUFFER_STATE " ++ name ++ "_scan_string(const char *str, yyscan_t scanner);" , "extern void " ++ name ++ "_delete_buffer(YY_BUFFER_STATE buf, yyscan_t scanner);" , ""- , "extern void " ++ name ++ "lex_destroy(yyscan_t scanner);"+ , "extern int " ++ name ++ "lex_destroy(yyscan_t scanner);" , "extern char* " ++ name ++ "get_text(yyscan_t scanner);" , "" , "extern yyscan_t " ++ name ++ "_initialize_lexer(FILE * inp);"@@ -160,23 +161,42 @@ unionDependentCode :: ParserMode -> String unionDependentCode mode = unlines [ "%{"- , errorHandler name+ , errorHandler mode , "int yyparse(yyscan_t scanner, YYSTYPE *result);" , "" , "extern int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner);" , "%}" ]- where- name = parserName mode -errorHandler :: String -> String-errorHandler name = unlines- [ "void yyerror(YYLTYPE *loc, yyscan_t scanner, YYSTYPE *result, const char *msg)"- , "{"- , " fprintf(stderr, \"error: %d,%d: %s at %s\\n\","- , " loc->first_line, loc->first_column, msg, " ++ name ++ "get_text(scanner));"- , "}"- ]+errorHandler :: ParserMode -> String+errorHandler mode = case mode of+ CParser _ _ ->+ -- This generates error handler for C with fprintf+ unlines+ [ "void yyerror(YYLTYPE *loc, yyscan_t scanner, YYSTYPE *result, const char *msg)"+ , "{"+ , " fprintf(stderr, \"error: %d,%d: %s at %s\\n\","+ , " loc->first_line, loc->first_column, msg, " ++ name ++ "get_text(scanner));"+ , "}"+ ]+ CppParser ns _ ->+ -- This generates error handler for C++ with throw parse_error+ unlines+ [ "void yyerror(YYLTYPE *loc, yyscan_t scanner, YYSTYPE *result, const char *msg)"+ , "{"+ , " std::string error_msg = msg;"+ , " if (loc) {"+ , " error_msg += \" at line \" + std::to_string(loc->first_line) +"+ , " \", column \" + std::to_string(loc->first_column);"+ , " }"+ , " if (scanner) {"+ , " error_msg += \": '\" + std::string(" ++ name ++ "get_text(scanner)) + \"'\";"+ , " }"+ , " throw " ++ maybe "" (++ "::") ns ++ "parse_error(loc ? loc->first_line : -1, error_msg);"+ , "}"+ ]+ where+ name = parserName mode -- | Parser entry point code. --@@ -194,7 +214,10 @@ , body False , [ "" , unwords [ "/* Entrypoint: parse", dat, "from string. */" ]- , dat ++ " ps" ++ parser ++ "(const char *str)"+ , dat ++ " p" ++ (if cParser mode then "s" else "") ++ parser ++ "(const char *str)"+ -- Andreas, 2026-01-26, issue #524+ -- In C++, functions can be overloaded, but not in C.+ -- So we need to give a different name to the string parser than to the file parser. ] , body True ]
src/BNFC/Backend/CPP/NoSTL.hs view
@@ -17,6 +17,7 @@ import BNFC.Backend.CPP.Common ( commentWithEmacsModeHint ) import BNFC.Backend.CPP.Makefile import BNFC.Backend.CPP.NoSTL.CFtoCPPAbs+import BNFC.Backend.CPP.STL ( mkEntryFuncs ) import BNFC.Backend.CPP.STL.CFtoCVisitSkelSTL import BNFC.Backend.CPP.PrettyPrinter import qualified BNFC.Backend.Common.Makefile as Makefile@@ -135,10 +136,8 @@ , "#include \"Absyn.H\"" , "" ]- , map mkFunc eps+ , concatMap mkEntryFuncs eps , [ "" , "#endif" ] ]- where- mkFunc s = identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(FILE *inp);"
src/BNFC/Backend/CPP/STL.hs view
@@ -7,7 +7,7 @@ -} -module BNFC.Backend.CPP.STL (makeCppStl,) where+module BNFC.Backend.CPP.STL (makeCppStl, mkEntryFuncs) where import Data.Foldable (toList) @@ -176,7 +176,7 @@ , "" , nsStart inPackage ]- , concatMap mkFuncs eps+ , concatMap mkEntryFuncs eps , [ nsEnd inPackage , "" , "#endif"@@ -184,7 +184,9 @@ ] where hdef = nsDefine inPackage "PARSER_HEADER_FILE"- mkFuncs s =++mkEntryFuncs :: Cat -> [String]+mkEntryFuncs s = [ identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(FILE *inp);" , identCat (normCat s) ++ "*" +++ "p" ++ identCat s ++ "(const char *str);" ]
src/BNFC/Backend/Txt2Tag.hs view
@@ -75,7 +75,7 @@ "" ] "String" -> ["String literals //String// have the form",- "``\"``//x//``\"``}, where //x// is any sequence of any characters",+ "``\"``//x//``\"``, where //x// is any sequence of any characters", "except ``\"`` unless preceded by ``\\``.", ""] "Integer" -> ["Integer literals //Integer// are nonempty sequences of digits.",@@ -104,9 +104,9 @@ else "Single-line comments begin with " ++ sing ++".", if null xs then- "There are no multiple-line comments in the grammar."+ " There are no multiple-line comments in the grammar." else- "Multiple-line comments are enclosed with " ++ mult ++"."+ " Multiple-line comments are enclosed with " ++ mult ++"." ] where sing = List.intercalate ", " $ map (symbol.prt) ys
stack-9.10.yaml view
@@ -1,1 +1,1 @@-resolver: lts-24.3+resolver: lts-24.28
stack-9.12.yaml view
@@ -1,3 +1,3 @@-resolver: nightly-2025-08-08+resolver: nightly-2025-10-14 compiler: ghc-9.12.2 compiler-check: newer-minor
stack-9.8.yaml view
@@ -1,4 +1,4 @@-resolver: lts-23.27+resolver: lts-23.28 compiler: ghc-9.8.4 compiler-check: newer-minor
test/BNFC/OptionsSpec.hs view
@@ -15,6 +15,7 @@ -- Expectation that a particular option has a particular value shouldSet :: (Eq a, Show a) => Mode -> (SharedOptions -> a, a) -> Expectation shouldSet (Target opts _) (option, value) = option opts `shouldBe` value+shouldSet _ _ = return () spec :: Spec spec = do