From f659274de250e2dfc5aa4ff7fb4fc395f81aa142 Mon Sep 17 00:00:00 2001 From: Commelina Date: Tue, 24 Mar 2026 23:56:17 +0100 Subject: [PATCH 1/2] [ testing ] add tree-sitter-cli to Dockerfile.test --- Dockerfile.test | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Dockerfile.test b/Dockerfile.test index 464cdcae..d33fb66f 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,3 +1,16 @@ +FROM rust:bookworm AS rust + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + clang && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# FIXME: Do not hard-code the version. +RUN cargo install --locked tree-sitter-cli@0.26.7 + +# ----------------------------------------------------------------------------- + FROM haskell:9.12.2-bookworm # Note: Do NOT hard-code package versions. They may get upgraded sometimes. @@ -16,13 +29,15 @@ RUN apt-get update && \ python3-pygments \ python3-setuptools \ virtualenv \ - python3-venv && \ + python3-venv \ + nodejs && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* RUN locale-gen C.UTF-8 ENV LANG=C.UTF-8 +# FIXME: Do not hard-code the version for the following tools. RUN cabal update RUN cabal install alex-3.5.4.0 happy-2.2 @@ -37,6 +52,24 @@ RUN curl -OL https://github.com/ndmitchell/hlint/releases/download/v3.10/hlint-3 rm -rf hlint-3.10 && \ rm -rf hlint-3.10-x86_64-linux.tar.gz +# Note: Recent `tree-sitter-cli` requires libc6>=2.39, while +# this image is based on 2.36, see https://hub.docker.com/_/haskell/. +# v0.24.7 seems to be the newest version supporting libc6-2.36. +# And we rely on some recent features of `tree-sitter-cli` (like `--cst` and +# parsing from stdin), that is why we build from source. +# +# If a newer `haskell` image with higher `libc6` version is published +# in the future, this may be replaced by directly downloading the pre-built +# binary like the commented following snippet (and remove the `rust` builder). + +# RUN curl -OL https://github.com/tree-sitter/tree-sitter/releases/download/v0.24.7/tree-sitter-linux-x64.gz && \ +# gzip -d tree-sitter-linux-x64.gz && \ +# chmod +x tree-sitter-linux-x64 && \ +# mv tree-sitter-linux-x64 /usr/bin/tree-sitter && \ +# rm -rf tree-sitter-linux-x64.gz + +COPY --from=rust /usr/local/cargo/bin/tree-sitter /usr/bin/tree-sitter + ENV CLASSPATH /bnfc/testing/data/JLex-1.2.6.jar:$CLASSPATH ENV CLASSPATH /bnfc/testing/data/java-cup-11b.jar:$CLASSPATH ENV CLASSPATH /bnfc/testing/data/java-cup-11b-runtime.jar:$CLASSPATH From fccadba6d539ca6d5e33e780ed4c4b020bc7d06f Mon Sep 17 00:00:00 2001 From: Commelina Date: Tue, 24 Mar 2026 23:57:12 +0100 Subject: [PATCH 2/2] [ testing ] reorganize ParameterizedTests & fix tests with tree-sitter backend --- testing/src/ParameterizedTests.hs | 394 +++++++++++++++++------------- testing/src/TestData.hs | 15 +- 2 files changed, 233 insertions(+), 176 deletions(-) diff --git a/testing/src/ParameterizedTests.hs b/testing/src/ParameterizedTests.hs index fc7ab540..7867a0a5 100644 --- a/testing/src/ParameterizedTests.hs +++ b/testing/src/ParameterizedTests.hs @@ -38,36 +38,66 @@ import Shelly #endif , when, withTmpDir, writefile -- , print_stdout, print_stderr + , setenv ) import TestUtils import TestData import OutputParser --- ~~~ TESTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Note (Commelina, 2026-03-24): +-- 1. Naming convention: +-- * functions which receive a @TestParameters@ are named @xxxWith@ +-- * runnable HTF @Test@s or @[Test]@s are named @xxxTest@ or @xxxTests@ +-- 2. 'current' and @currentXXXTest@s are NOT used now: they are present +-- mostly for historical reasons. + +---------------------------------------------------------------------- +-- Exposed tests +---------------------------------------------------------------------- all :: Test -all = makeTestSuite "Parameterized tests" [allWithParams p | p <- parameters ] +all = makeTestSuite "Parameterized tests" $ concat + [ map distcleanTestWith (parameters `excludeParameter` treeSitterParameters) + , regressionTests + , map exitCodeTestWith parameters + , map entrypointTestWith parameters + , map exampleTestsWith parameters + ] -allWithParams :: TestParameters -> Test -allWithParams params = makeTestSuite (tpName params) $ concat $ - [ distcleanTest params ] : - testCases params : - [ exitCodeTest params ] : - [ entrypointTest params ] : - [ exampleTests params ] : - [] +-- | Layout currently only works for Haskell (even Agda) and Haskell/GADT. +layoutTest :: Test +layoutTest = makeTestSuite "Layout parsing test" $ concat + [ map (`makeTestCase` ("regression-tests" "399_TopLayoutStop")) $ + [ haskellStartPosParameters + ] + , map (`makeTestCase` ("regression-tests" "356_LayoutSnocList")) $ + [ haskellParameters + ] + , map (`makeTestCase` ("regression-tests" "194_layout")) $ + [ haskellGADTParameters + , haskellAgdaParameters + ] + , map (`makeTestCase` ("regression-tests" "352_TopLayoutOnly")) $ + [ haskellParameters + ] + , let p = haskellStartPosParameters + in [ makeTestSuite (tpName p) $ mapMaybe (exampleTestWith p) layoutExamples ] + ] + +---------------------------------------------------------------------- +-- Legacy code, NOT used now +---------------------------------------------------------------------- -- | This parameterized test is called first. -- Use it while working in connection with a certain test case. (For quicker response.) current :: Test -- current = currentExampleTest --- current = currentRegressionTest -current = makeTestSuite "TS" [allWithParams p | p <- parameters ] +current = currentRegressionTest -- current = layoutTest currentExampleTest :: Test currentExampleTest = makeTestSuite "Current parameterized test" $ - mapMaybe (`exampleTest` (exampleGrammars !! 3)) parameters + mapMaybe (`exampleTestWith` (exampleGrammars !! 3)) parameters currentRegressionTest :: Test currentRegressionTest = makeTestSuite "Current parameterized test" $ @@ -89,26 +119,6 @@ currentRegressionTest = makeTestSuite "Current parameterized test" $ -- cur = "194_layout" -- cur = "210_NumberedCatWithoutCoerce" --- | Layout currently only works for Haskell (even Agda) and Haskell/GADT. -layoutTest :: Test -layoutTest = makeTestSuite "Layout parsing test" $ concat - [ map (`makeTestCase` ("regression-tests" "399_TopLayoutStop")) $ - [ haskellStartPosParameters - ] - , map (`makeTestCase` ("regression-tests" "356_LayoutSnocList")) $ - [ haskellParameters - ] - , map (`makeTestCase` ("regression-tests" "194_layout")) $ - [ haskellGADTParameters - , haskellAgdaParameters - ] - , map (`makeTestCase` ("regression-tests" "352_TopLayoutOnly")) $ - [ haskellParameters - ] - , let p = haskellStartPosParameters - in [ makeTestSuite (tpName p) $ mapMaybe (exampleTest p) layoutExamples ] - ] - -- #254 is now covered by fail-lbnf/254-empty-input -- -- | BNFC should not proceed if grammar does not define any rules. -- noRulesTest :: TestParameters -> Test @@ -122,10 +132,27 @@ layoutTest = makeTestSuite "Layout parsing test" $ concat -- unless (Text.isInfixOf "ERROR" err) $ -- assertFailure "Expected BNFC to die with ERROR message." +---------------------------------------------------------------------- +-- Concrete tests (or test generators) used by exposed tests +---------------------------------------------------------------------- + +-- | To test that @distclean@ removes all generated files. +distcleanTestWith :: TestParameters -> Test +distcleanTestWith params = + makeShellyTest "distclean removes all generated files" $ withTmpDir $ \tmp -> do + cd tmp + let cfFile = "G.cf" + writefile cfFile "L. C ::= \"t\" ;" + tpBnfc params cfFile + tpBuild params + tpDistclean + dContents <- ls "." + assertEqual [cfFile] (map takeFileName dContents) + -- | This tests checks that when given an invalid input, the generated example -- application exits with a non-zero exit code. -exitCodeTest :: TestParameters -> Test -exitCodeTest params = +exitCodeTestWith :: TestParameters -> Test +exitCodeTestWith params = makeShellyTest "Test program exits with code 1 on failure" $ withTmpDir $ \tmp -> do cd tmp @@ -141,8 +168,8 @@ exitCodeTest params = -- | This tests that the generated parser abide to the entrypoint directive -- (see issue #127) -entrypointTest :: TestParameters -> Test -entrypointTest params = +entrypointTestWith :: TestParameters -> Test +entrypointTestWith params = makeShellyTest "Respects entrypoint directive" $ withTmpDir $ \tmp -> do cd tmp writefile "foobar.cf" "entrypoints Foo;" @@ -161,19 +188,76 @@ entrypointTest params = -- | Runs BNFC on the example grammars, build the generated code and, if -- example in the grammar's language are available, tries to parse the -- examples with the generated test program. -exampleTests :: TestParameters -> Test -exampleTests params = - makeTestSuite "Examples" $ mapMaybe (exampleTest params) exampleGrammars +exampleTestsWith :: TestParameters -> Test +exampleTestsWith params = + makeTestSuite "Examples" $ mapMaybe (exampleTestWith params) exampleGrammars -- filter (not . excluded) exampleGrammars -- where -- excluded :: Example -> Bool -- excluded (Example' exclude _ _) = any (tpName params =~) exclude +-- | To test certain grammatical constructions or interactions between rules, +-- test grammar can be created under the regression-tests directory, +-- together with valid and invalid inputs. +regressionTests :: [Test] +regressionTests = concat + [ -- Note: Disabled on 2026-03-04. The Java backend does not support + -- labels with only different cases. See + -- https://github.com/BNFC/bnfc/issues/479. + -- + -- "479_LabelsCaseSensitive" + + -- Note: Disabled on 2026-03-04. It fails on the c backend. + -- See https://github.com/BNFC/bnfc/issues/266. + -- + -- , "266_define" + + withParams "358_MixFixLists" parameters + , withParams "235_SymbolsOverlapTokens" parameters + , withParams "278_Keywords" parameters + , withParams "256_Regex" parameters + , withParams "222_IntegerList" parameters + , withParams "70_WhiteSpaceSeparator" parameters + + -- Note: Disabled on 2026-03-04. It fails on ocaml and ocaml-menhir + -- backends, see https://github.com/ocaml/ocaml/issues/9964. + -- + -- , "202_comments" + + , withParams "210_NumberedCatWithoutCoerce" parameters + , withParams "204_InternalToken" parameters + + -- Note: Disabled on 2026-03-24 (tree-sitter). + -- It seems that the current tree-sitter backend does not + -- support unicode symbols very well. + , withParams "249_unicode" (parameters `excludeParameter` treeSitterParameters) + + -- Note: Disabled on 2026-03-04. It: + -- * fails on ocaml and ocaml-menhir backends, see + -- https://github.com/ocaml/ocaml/issues/9964. + -- * fails on the haskell-gadt backend, see + -- https://github.com/BNFC/bnfc/issues/280#issuecomment-830844433. + -- + -- , "289_LexerKeywords" + + , withParams "100_coercion_lists" parameters + , withParams "comments" parameters + , withParams "149" parameters + ] + + where + withParams dir params = + map (`makeTestCase` ("regression-tests" dir)) params + +---------------------------------------------------------------------- +-- Helpers for building tests +---------------------------------------------------------------------- + -- | Construct a test from an example grammar and test inputs, -- unless the test parameters are contained in the exclusion list -- or not contained in the inclusion list. -exampleTest :: TestParameters -> Example -> Maybe Test -exampleTest params (Example' limit grammar examples) +exampleTestWith :: TestParameters -> Example -> Maybe Test +exampleTestWith params (Example' limit grammar examples) | Excluded exclude <- limit, any (tpName params =~) exclude = Nothing | Included include <- limit, not $ any (tpName params =~) include = Nothing | otherwise = Just $ @@ -187,57 +271,15 @@ exampleTest params (Example' limit grammar examples) forM_ examples $ \example -> tpRunTestProg params lang [takeFileName example] --- | To test certain grammatical constructions or interactions between rules, --- test grammar can be created under the regression-tests directory, --- together with valid and invalid inputs. -testCases :: TestParameters -> [Test] -testCases params = - map (makeTestCase params) $ - map ("regression-tests/" ++) $ - [ - -- Note: Disabled on 2026-03-04. The Java backend does not support - -- labels with only different cases. See - -- https://github.com/BNFC/bnfc/issues/479. - -- - -- "479_LabelsCaseSensitive" - - -- Note: Disabled on 2026-03-04. It fails on the c backend. - -- See https://github.com/BNFC/bnfc/issues/266. - -- - -- , "266_define" - - "358_MixFixLists" - , "235_SymbolsOverlapTokens" - , "278_Keywords" - , "256_Regex" - , "222_IntegerList" - , "70_WhiteSpaceSeparator" - - -- Note: Disabled on 2026-03-04. It fails on ocaml and ocaml-menhir - -- backends, see https://github.com/ocaml/ocaml/issues/9964. - -- - -- , "202_comments" - - , "210_NumberedCatWithoutCoerce" - , "204_InternalToken" - , "249_unicode" - - -- Note: Disabled on 2026-03-04. It: - -- * fails on ocaml and ocaml-menhir backends, see - -- https://github.com/ocaml/ocaml/issues/9964. - -- * fails on the haskell-gadt backend, see - -- https://github.com/BNFC/bnfc/issues/280#issuecomment-830844433. - -- - -- , "289_LexerKeywords" - - , "100_coercion_lists" - , "comments" - , "149" - ] - makeTestCase :: TestParameters -> FilePath -> Test makeTestCase params dir = makeShellyTest (mkTitle dir) $ withTmpDir $ \tmp -> do + -- Note (Commelina, 2026-03-25): + -- tree-sitter uses a global library cache by default, + -- which can cause errors when working with grammars with + -- the same name in parallel. + setenv "TREE_SITTER_LIBDIR" (Text.pack tmp <> "_lib") + dir <- absPath dir dirContents <- ls dir -- Note: these are absolute filenames! cd tmp @@ -256,7 +298,8 @@ makeTestCase params dir = gold <- readfile (replaceExtension f "out") let (_, goldLT) = parseOutput gold (_, actualLT) = parseOutput output - assertEqual goldLT actualLT + when (tpShouldGoldenCheckLin params) $ + assertEqual goldLT actualLT let bad = filter (matchFilePath "bad[0-9]*[.]in$") dirContents forM_ bad $ \f -> do errExit False $ tpRunTestProg params testFile [f] @@ -264,20 +307,10 @@ makeTestCase params dir = where mkTitle dir = tpName params ++ ":" ++ takeFileName dir --- | To test that @distclean@ removes all generated files. -distcleanTest :: TestParameters -> Test -distcleanTest params = - makeShellyTest "distclean removes all generated files" $ withTmpDir $ \tmp -> do - cd tmp - let cfFile = "G.cf" - writefile cfFile "L. C ::= \"t\" ;" - tpBnfc params cfFile - tpBuild params - tpDistclean - dContents <- ls "." - assertEqual [cfFile] (map takeFileName dContents) +---------------------------------------------------------------------- +-- Parameters +---------------------------------------------------------------------- --- ~~~ Parameters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Test parameters are the combination of bnfc options (that define the -- backend to use) a build command to compile the resulting parser and a run -- command to run the test program. @@ -290,8 +323,15 @@ data TestParameters = TP tpBuild :: Sh () , -- | Command for running the test executable with the given arguments tpRunTestProg :: FilePath -> [FilePath] -> Sh Text + , -- | Whether to compare the @[Linearized tree]@ part + tpShouldGoldenCheckLin :: Bool } +-- | Exclude certain @TestParameters@ from a list by @tpName@. +excludeParameter :: [TestParameters] -> TestParameters -> [TestParameters] +excludeParameter params param = + filter ((/= tpName param) . tpName) params + baseParameters :: TestParameters baseParameters = TP { tpName = undefined @@ -300,6 +340,7 @@ baseParameters = TP , tpRunTestProg = \ lang args -> do bin <- baseTestProg lang cmd bin args + , tpShouldGoldenCheckLin = True } -- | Get the test binary. @@ -318,6 +359,7 @@ haskellParameters = TP -- cmd "ghc" "-XNoImplicitPrelude" "-Wall" "-Werror" . (:[]) =<< findFileRegex "Skel.*\\.hs$" , tpRunTestProg = haskellRunTestProg + , tpShouldGoldenCheckLin = True } haskellStartPosParameters :: TestParameters @@ -338,6 +380,7 @@ haskellGADTParameters = TP , tpBnfcOptions = ["--haskell-gadt"] , tpBuild = haskellBuild , tpRunTestProg = haskellRunTestProg + , tpShouldGoldenCheckLin = True } haskellAgdaParameters :: TestParameters @@ -359,66 +402,37 @@ haskellAgdaRangePosParameters = haskellAgdaParameters , tpBnfcOptions = ["--haskell", "--agda", "--positions=range"] } --- | Run 'hlint' at current directory with certain hints ignored. -hlintCheck :: Sh () -hlintCheck = cmd "hlint" - "-i" "Avoid lambda" - "-i" "Avoid lambda using `infix`" - "-i" "Eta reduce" - "-i" "Redundant bracket" - "-i" "Redundant lambda" - "-i" "Redundant $" - "-i" "Use camelCase" - "-i" "Use newtype instead of data" - "-i" "Use fmap" - - -- Note: Newer hlint warns on the following code in ErrM.hs: - -- import Control.Monad (MonadPlus(..)) - -- #if __GLASGOW_HASKELL__ >= 808 - -- import Control.Monad (MonadFail(..)) - -- #endif - "-i" "Use fewer imports" - - "-i" "Unused LANGUAGE pragma" - "." - --- | Invoke the Makefile with GHC-specific options. -haskellBuild :: Sh () -haskellBuild = tpMake [ "GHC_OPTS=-XNoImplicitPrelude -Wall -Werror" ] - --- Note (Commelina, 2026-03-06): --- Agda calls GHC with @-O@ flag (at least on 2026-03-06, v2.8.0), --- and requires the implicit @Prelude@ for compiling @MAlonzo\/\*@. --- To avoid slow re-compilation of @AbsXXX.hs@, we slightly altered --- the flags here. --- --- If there is any further problem (for example, false negative --- without @-XNoImplicitPrelude@), please change the following flags. --- | Invoke the Makefile with GHC- and Agda- specific options. -agdaBuild :: Sh () -agdaBuild = tpMake [ "GHC_OPTS=-Wall -Werror" - , "AGDA_OPTS=--ghc-flag=-O0" - ] +ocamlParameters :: TestParameters +ocamlParameters = TP + { tpName = "OCaml" + , tpBuild = tpMake ["OCAMLCFLAGS=-safe-string"] + , tpBnfcOptions = ["--ocaml"] + , tpRunTestProg = haskellRunTestProg + , tpShouldGoldenCheckLin = True + } --- | Haskell backend: default command for running the test executable with the given arguments. -haskellRunTestProg :: FilePath -> [FilePath] -> Sh Text -haskellRunTestProg _lang args = do - -- cmd "echo" "Looking for Test* binary" - -- -- can't print anything here because then the setStdin input is used up here - bin <- findFileRegex "Test[^.]*$" - -- cmd "echo" "Running" bin -- ditto - -- print_stdout True $ print_stderr True $ do - cmd bin args +treeSitterParameters :: TestParameters +treeSitterParameters = TP + { tpName = "tree-sitter" + , tpBuild = do + cmd "tree-sitter" "generate" . (:[]) =<< findFile "grammar.js" + , tpBnfcOptions = ["--tree-sitter"] + , tpRunTestProg = \ _lang args -> do + cmd "tree-sitter" "parse" args + -- Note: tree-sitter does not have a builtin pretty-printer, + -- so we disable checks for linearized output here. + , tpShouldGoldenCheckLin = False + } parameters :: [TestParameters] parameters = concat [ [] -- OCaml/Menhir - , [ ocaml { tpName = "OCaml/Menhir" - , tpBnfcOptions = ["--ocaml", "--menhir"] } + , [ ocamlParameters { tpName = "OCaml/Menhir" + , tpBnfcOptions = ["--ocaml", "--menhir"] } ] -- OCaml - , [ ocaml ] + , [ ocamlParameters ] -- Functor (Haskell & Agda) , [ haskellAgdaStartPosParameters , haskellAgdaRangePosParameters @@ -454,6 +468,7 @@ parameters = concat -- "--show-leak-kinds=definite" : -- bin : -- args + , tpShouldGoldenCheckLin = True } , cBase { tpName = "C (with line numbers)" , tpBnfcOptions = ["--c", "--line-numbers"] } @@ -496,7 +511,7 @@ parameters = concat , tpBnfcOptions = ["--java", "--jflex", "-l"] } ] -- Tree-sitter - , [ treeSitter ] + , [ treeSitterParameters ] ] where base = baseParameters @@ -514,20 +529,57 @@ parameters = concat class_ <- dropExtension <$> findFile "Test.class" cmd "java" $ "-Xss16M" : class_ : args } - ocaml = TP - { tpName = "OCaml" - , tpBuild = tpMake ["OCAMLCFLAGS=-safe-string"] - , tpBnfcOptions = ["--ocaml"] - , tpRunTestProg = haskellRunTestProg - } - treeSitter = TP - { tpName = "tree-sitter" - , tpBuild = do - cmd "tree-sitter" "generate" . (:[]) =<< findFile "grammar.js" - , tpBnfcOptions = ["--tree-sitter"] - , tpRunTestProg = \ _lang args -> do - cmd "tree-sitter" "parse" args - } + +-- | Run 'hlint' at current directory with certain hints ignored. +hlintCheck :: Sh () +hlintCheck = cmd "hlint" + "-i" "Avoid lambda" + "-i" "Avoid lambda using `infix`" + "-i" "Eta reduce" + "-i" "Redundant bracket" + "-i" "Redundant lambda" + "-i" "Redundant $" + "-i" "Use camelCase" + "-i" "Use newtype instead of data" + "-i" "Use fmap" + + -- Note: Newer hlint warns on the following code in ErrM.hs: + -- import Control.Monad (MonadPlus(..)) + -- #if __GLASGOW_HASKELL__ >= 808 + -- import Control.Monad (MonadFail(..)) + -- #endif + "-i" "Use fewer imports" + + "-i" "Unused LANGUAGE pragma" + "." + +-- | Invoke the Makefile with GHC-specific options. +haskellBuild :: Sh () +haskellBuild = tpMake [ "GHC_OPTS=-XNoImplicitPrelude -Wall -Werror" ] + +-- Note (Commelina, 2026-03-06): +-- Agda calls GHC with @-O@ flag (at least on 2026-03-06, v2.8.0), +-- and requires the implicit @Prelude@ for compiling @MAlonzo\/\*@. +-- To avoid slow re-compilation of @AbsXXX.hs@, we slightly altered +-- the flags here. +-- +-- If there is any further problem (for example, false negative +-- without @-XNoImplicitPrelude@), please change the following flags. +-- | Invoke the Makefile with GHC- and Agda- specific options. +agdaBuild :: Sh () +agdaBuild = tpMake [ "GHC_OPTS=-Wall -Werror" + , "AGDA_OPTS=--ghc-flag=-O0" + ] + +-- | Haskell backend: default command for running the test executable with the given arguments. +haskellRunTestProg :: FilePath -> [FilePath] -> Sh Text +haskellRunTestProg _lang args = do + -- cmd "echo" "Looking for Test* binary" + -- -- can't print anything here because then the setStdin input is used up here + bin <- findFileRegex "Test[^.]*$" + -- cmd "echo" "Running" bin -- ditto + -- print_stdout True $ print_stderr True $ do + cmd bin args -- | Helper function that runs bnfc with the context's options and an -- option to generate 'tpMakefile'. diff --git a/testing/src/TestData.hs b/testing/src/TestData.hs index aaae7402..1730bc4c 100644 --- a/testing/src/TestData.hs +++ b/testing/src/TestData.hs @@ -51,16 +51,20 @@ exampleGrammars = map (fmap prefix) $ -- https://github.com/BNFC/bnfc/issues/266. , fmap ("define" ) $ Example' noDefine "test.cf" [ "good01.in" ] + -- Note: The tree-sitter backend does not check ambigious grammar, + -- which brings an error when generating parsers via @tree-sitter build@. + , fmap ("GF" ) $ Example' noTreeSitter "gf.cf" [ "example.gf" ] + , fmap ("C" ) $ Example' noTreeSitter "C.cf" [ "runtime.c", "koe2.c", "core.c" ] + , fmap ("C" ) $ Example' noTreeSitter "C4.cf" [ "koe2.c" ] + , fmap ("Java" ) $ Example' (Excluded ["antlr", "tree-sitter"]) "java.cf" [] + -- ANTLR cannot handle mutual left recursion in java.cf + , fmap ("cpp" ) $ Example "cpp.cf" [ "example.cpp" ] - , fmap ("GF" ) $ Example "gf.cf" [ "example.gf" ] , fmap ("OCL" ) $ Example "OCL.cf" [ "example.ocl" ] , fmap ("prolog" ) $ Example "Prolog.cf" [ "small.pl", "simpsons.pl" ] - , fmap ("C" ) $ Example "C.cf" [ "runtime.c", "koe2.c", "core.c" ] - , fmap ("C" ) $ Example "C4.cf" [ "koe2.c" ] , fmap ("Javalette" ) $ Example "JavaletteLight.cf" [ "koe.jll" ] , fmap ("LBNF" ) $ Example "LBNF.cf" [ "LBNF.cf" ] - , fmap ("Java" ) $ Example' (Excluded ["antlr"]) "java.cf" [] - -- ANTLR cannot handle mutual left recursion in java.cf + , Example "Calc.cf" [] , Example "fstStudio.cf" [] ] @@ -72,6 +76,7 @@ exampleGrammars = map (fmap prefix) $ noDefine = Excluded ["^C$", "^C.*numbers.*$"] -- noJava = "^Java" -- begins with "Java" -- noCPP = "^C\\+\\+" -- begins with "C++" + noTreeSitter = Excluded ["tree-sitter"] layoutExamples :: [Example] layoutExamples = take 2 exampleGrammars