diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-06-16 14:57:14 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-06-16 14:57:14 +0300 |
commit | b28e50ac4cf013eb68f6d3a10b07f8683bd60122 (patch) | |
tree | 04d704f4d28465aba3076f5d0d68a9aa44d68610 /ftt-codegen | |
parent | 854d2349a9800cd93bac3897fa705e53ac8b50ed (diff) | |
download | fable-poc-b28e50ac4cf013eb68f6d3a10b07f8683bd60122.tar.gz |
Fix: encode args as JSON, to get around difficult chars in captures
Diffstat (limited to 'ftt-codegen')
-rwxr-xr-x | ftt-codegen | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ftt-codegen b/ftt-codegen index f8a57b4..c54a383 100755 --- a/ftt-codegen +++ b/ftt-codegen @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import copy +import json import re import sys @@ -9,7 +10,7 @@ import yaml hardcoded = ''' -import fable +import fable, json run = fable.Run() ''' @@ -112,13 +113,12 @@ def find_binding(bindings, keyword, rest): def codegen(f, step, bindings): words = step.split() + if not words: + return keyword = words[0] rest = ' '.join(words[1:]) function, args = find_binding(bindings, keyword, rest) - f.write('args = {\n') - for arg in args: - f.write('"{}": "{}"\n'.format(arg, args[arg])) - f.write('}\n') + f.write('args = {}\n'.format(json.dumps(args))) f.write('{}(run.get_context(), **args)\n'.format(function)) def debug(msg): |