Skip to content

Parsing @do arguments is broken #97

@rburny

Description

@rburny

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 @do anyway. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions