mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
added explicit depth parameter to the parsing API and the corresponding command in the shell
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user