diff options
| author | krasimir <krasimir@chalmers.se> | 2010-10-18 16:51:25 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2010-10-18 16:51:25 +0000 |
| commit | 775e59dabeb6d1e15a3c1c80d7578a865121b9cf (patch) | |
| tree | b46e85b17fa124b9508058f6069bb8c268424174 /src/compiler | |
| parent | 205ac48ac3f96c938e6650c2a610e3e637af5570 (diff) | |
added explicit depth parameter to the parsing API and the corresponding command in the shell
Diffstat (limited to 'src/compiler')
| -rw-r--r-- | src/compiler/GF/Command/Commands.hs | 11 | ||||
| -rw-r--r-- | src/compiler/GF/Compile/ExampleBased.hs | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index d27bea37e..b10d35ec7 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -492,7 +492,8 @@ allCommands env@(pgf, mos) = Map.fromList [ flags = [ ("cat","target category of parsing"), ("lang","the languages of parsing (comma-separated, no spaces)"), - ("openclass","list of open-class categories for robust parsing") + ("openclass","list of open-class categories for robust parsing"), + ("depth","maximal depth for proof search if the abstract syntax tree has meta variables") ], options = [ ("bracket","prints the bracketed string from the parser") @@ -902,8 +903,10 @@ allCommands env@(pgf, mos) = Map.fromList [ ] where par opts s = case optOpenTypes opts of - [] -> [parse_ pgf lang (optType opts) s | lang <- optLangs opts] - open_typs -> [parseWithRecovery pgf lang (optType opts) open_typs s | lang <- optLangs opts] + [] -> [parse_ pgf lang (optType opts) (Just dp) s | lang <- optLangs opts] + open_typs -> [parseWithRecovery pgf lang (optType opts) open_typs (Just dp) s | lang <- optLangs opts] + where + dp = valIntOpts "depth" 4 opts void = ([],[]) @@ -993,7 +996,7 @@ allCommands env@(pgf, mos) = Map.fromList [ Just ty -> case checkType pgf ty of Left tcErr -> error $ render (ppTcError tcErr) Right ty -> ty - Nothing -> error ("Can't parse '"++str++"' as type") + Nothing -> error ("Can't parse '"++str++"' as a type") optComm opts = valStrOpts "command" "" opts optViewFormat opts = valStrOpts "format" "png" opts optViewGraph opts = valStrOpts "view" "open" opts diff --git a/src/compiler/GF/Compile/ExampleBased.hs b/src/compiler/GF/Compile/ExampleBased.hs index 46fb8b5d7..24944d9b6 100644 --- a/src/compiler/GF/Compile/ExampleBased.hs +++ b/src/compiler/GF/Compile/ExampleBased.hs @@ -41,7 +41,7 @@ convertFile conf src file = do convEx (cat,ex) = do appn "(" let typ = maybe (error "no valid cat") id $ readType cat - ws <- case fst (parse_ pgf lang typ ex) of + ws <- case fst (parse_ pgf lang typ (Just 4) ex) of ParseFailed _ -> do let ws = morphoMissing morpho (words ex) appv ("WARNING: cannot parse example " ++ ex) |
