-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
I have found a situation where I cannot pass data to a previously defined macro. Here is an example snippet:
@macro (test)
:echomsg "[]"
~ {res}
@endmacro
@do (test, res="[]")
which fails with ERROR on line 26: Unrecognized directive "do (test, res='[]')"
The underlying issue is that each directive must much the following regexp:
r'( .*) \(\s*([%><=\'"\w\d.+,$ ]*)\s*\)$'
which doesn't allow square brackets.
Naive solution would be to simply extend this regexp to allow more characters. However, I suggest reimplementing @do completely. There are two reasons for that:
- other control blocks have much more restricted argument format, and should be left with stricter validation
- naive control block parsing (which splits it on comma) does not work for
@doanyway. For example,@do (test, res="1,2")fails due to erroenously splitting string argument in half:
File "/usr/local/google/home/rburny/vroom/vroom/actions.py", line 346, in ParseCall
kwargs[k.strip()] = eval(v)
File "<string>", line 1
"1
^
SyntaxError: EOL while scanning string literal
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels