diff options
| author | hallgren <hallgren@chalmers.se> | 2015-08-26 13:56:23 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2015-08-26 13:56:23 +0000 |
| commit | 128236eab9f24f7085e1378d3f78306d9cad0658 (patch) | |
| tree | 9d8f0647a8006385fdaf6862769650c52e3a1b2e /src/compiler/GF/JavaScript | |
| parent | 32d5d4b52f37b8c421291a0cd8b77ada8d71fac2 (diff) | |
GF shell: change parse & linearize to obtain useful results from p|l and l|p in more cases
These changes are inspired by the gf -cshell implementation of these commands.
The output of the linearize command has been changed to remove superfluous
blank lines and commas, and deliver the result as a list of strings instead of
a single multi-line string. This makes it possible to use -all and pipe the
results to the parse command. This also means that with -treebank -all,
the language tag will be repeated for each result from the same language.
The parse command, when trying to parse with more than one language, would
"forget" other results after a failed parse, and thus not send all
successful parses through the pipe. For example, if English is not the first
language in the grammar,
p "hello" | l
would output nothing, instead of translations of "hello" to all languages,
forcing the user to write
p -lang=Eng "hello" | l
instead, to get the expected result. The cause of this behaviour was in the
function fromParse, which was rather messy, so I assume it is not intentional,
but the result of a programming mistake at some point.
The fromParse function has now been refactored from a big recursive function
into
fromParse opts = foldr (joinPiped . fromParse1 opts) void
where the helper functions fromParse1 deals with a single parse result and
joinPiped combines multiple parse results.
Diffstat (limited to 'src/compiler/GF/JavaScript')
0 files changed, 0 insertions, 0 deletions
