Speaking with my l10n-tool-developer hat on, I prefer option A, which makes
source strings available directly.

-Matjaž

On Fri, May 1, 2015 at 5:07 PM, Zibi Braniecki <[email protected]
> wrote:

> Hi Matjaž,
>
> Yes, it very much is. In L20n grammar [0] we define strings as complex
> structures which can contain so called expanders.
>
> In runtime we optimize it by separating simple and complex strings. Simple
> string is just a string:
>
> <foo "hey world!">
>
> Complex string is an Array|List or strings and expressions:
>
> <foo "one {{ n }} two {{ $m }}">
>
> The latter will produce:
> [
>   "one ",
>   {t: "id", v: "n"},
>   " two ",
>   {t: "var", v: "m"}
> ]
>
> It actually is not a naive optimization. Because of the way expanders
> work, I cannot in the parser find the end of the string without parsing the
> expanders. Look at this:
>
> <foo "Hello {{ @global("foo") }}">
>
> Without lexing the string, I would have to assume that the end of the
> string is at global(". In the old days (huh!) we tried to approach of
> double parsing - where such an entity would require escaped quotes and then
> would be double-parser, first time to just find the whole string (and
> remove backslashes), second to parse expander in the string[1]:
>
> <foo "Hello {{ @global(\"foo\") }}">
>
> This unfortunately didn't work [2] (I'd like to point out that arguments
> for double-parsing and against double-parsing were raised, with the full
> power of reason, by Stas over the span of two days. Stas is amazing).
>
> ===============
>
> Bottom line is that I believe that parser should store parsed complex
> string. What we may want to do is:
>
> a) Store a source of the string as well
>
> which would require the Array|List of a complex string to be turned into
> an object with {'v': [], 's': "..."} value and source.
>
> b) Let you serialize and parse string easily
>
> which would keep the AST as it is, but you'd have access to
> Serializer.serializeString() and Parser.parseString() which you'd be using
> whenever a value is an Array|List.
>
> How does it sound to you?
>
> zb.
>
>
> [0] http://l20n.github.io/spec/grammar.html
> [1] https://bugzilla.mozilla.org/show_bug.cgi?id=918655#c11 ,
> https://bugzilla.mozilla.org/show_bug.cgi?id=918655#c16
> [2] https://bugzilla.mozilla.org/show_bug.cgi?id=918655
> _______________________________________________
> tools-l10n mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/tools-l10n
>
_______________________________________________
tools-l10n mailing list
[email protected]
https://lists.mozilla.org/listinfo/tools-l10n

Reply via email to