[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] simplebench: add img_bench_templater.py
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [PATCH 1/3] simplebench: add img_bench_templater.py |
Date: |
Tue, 24 Aug 2021 12:09:45 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 |
24.08.2021 11:59, Hanna Reitz wrote:
On 24.08.21 10:53, Vladimir Sementsov-Ogievskiy wrote:
19.08.2021 19:37, Hanna Reitz wrote:
On 24.07.21 15:38, Vladimir Sementsov-Ogievskiy wrote:
[...]
+import itertools
+from lark import Lark
+
+grammar = """
+start: ( text | column_switch | row_switch )+
+
+column_switch: "{" text ["|" text]+ "}"
+row_switch: "[" text ["|" text]+ "]"
+text: /[^|{}\[\]]+/
So I have no idea how this really works, of course, but does this mean that the
`text` pattern cannot contain pipe symbols? I.e. that you cannot use pipes in
the test template?
Hmm. I didn't try. I hope lark is smart enough to keep pipes that are out of {}
[] as is.. But of course, you can't hope that pipe inside {} or [] will work as
bash-pipe.
Yep, sure. It’s just that the `text` nonterminal symbol doesn’t look like it
could match anything with a pipe in it.
Oops, right. To avoid it, we'll have to split text into "text_inside_brackets" and
"text_outside_of_brackets".. As well, let's postpone this complication until we really
need it.
Same thing with other special symbols ("{}" and "[]"). I don't want to care
about this too much now. This simple grammar works good for test template in patch 03. If we need
something more, we can add a kind of special symbols escaping later.
But yes, if someone trips over this (i.e. we ourselves), we can still fix it
then.
Hanna
--
Best regards,
Vladimir