From 8729339d2603a7e18ef05a31bfd47f299084cb8f Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 5 Sep 2016 21:15:44 +0000 Subject: [PATCH] BNF grammars (.bnf or .cf) can have rules without semicolons, as in the GF book examples. However, if the grammar has any multiline rules, all of them must have semicolons. --- src/compiler/GF/Compile/GetGrammar.hs | 13 ++++++++++--- src/runtime/java/Makefile | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/compiler/GF/Compile/GetGrammar.hs b/src/compiler/GF/Compile/GetGrammar.hs index c8a32ccc6..0813d15d2 100644 --- a/src/compiler/GF/Compile/GetGrammar.hs +++ b/src/compiler/GF/Compile/GetGrammar.hs @@ -66,11 +66,18 @@ getSourceModule opts file0 = getBNFCRules :: Options -> FilePath -> IOE [BNFCRule] getBNFCRules opts fpath = do raw <- liftIO (BS.readFile fpath) +---- debug BS.putStrLn $ raws (optCoding,parsed) <- parseSource opts pBNFCRules raw case parsed of - Left (Pn l c,msg) -> do cwd <- getCurrentDirectory - let location = makeRelative cwd fpath++":"++show l++":"++show c - raise (location++":\n "++msg) + Left _ -> do + let ifToChange s ss = if (BS.all (\c -> elem c [' ','\t']) s || BS.last s == ';') then s else ss -- change if not all space or end with ';' + let raws = BS.concat $ map (\s -> ifToChange s $ BS.concat [s,BS.singleton ';']) $ BS.split '\n' raw -- add semicolon to each line to be able to parse the format in GF book + (optCoding,parseds) <- parseSource opts pBNFCRules raws + case parseds of + Left (Pn l c,msg) -> do cwd <- getCurrentDirectory + let location = makeRelative cwd fpath++":"++show l++":"++show c + raise (location++":\n "++msg) + Right rules -> return rules Right rules -> return rules getEBNFRules :: Options -> FilePath -> IOE [ERule] diff --git a/src/runtime/java/Makefile b/src/runtime/java/Makefile index 6bf0d1495..52342ac27 100644 --- a/src/runtime/java/Makefile +++ b/src/runtime/java/Makefile @@ -2,10 +2,18 @@ C_SOURCES = jpgf.c jsg.c jni_utils.c JAVA_SOURCES = $(wildcard org/grammaticalframework/pgf/*.java) \ $(wildcard org/grammaticalframework/sg/*.java) +v v v v v v v +JNI_PATH = /usr/lib/jvm/default-java/include +============= +#JNI_PATH = /usr/lib/jvm/default-java/include +JNI_PATH = /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/ +************* JNI_PATH = $(if $(wildcard /usr/lib/jvm/default-java/include/.*), /usr/lib/jvm/default-java/include, \ $(if $(wildcard /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/.*), /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, \ $(error No JNI headers found))) +^ ^ ^ ^ ^ ^ ^ INSTALL_PATH = /usr/local/lib +LIBTOOL = glibtool --tag=CC LIBTOOL = $(if $(shell command -v glibtool 2>/dev/null), glibtool --tag=CC, libtool)