On Mon, Feb 25, 2019 at 05:22:51PM +0100, Pino Toscano wrote:
[...]
After being burned a few times with custom parsing (hello, guestfish)
I'm not a big fan.
Is there not an existing C or OCaml library/facility we could use
here? It's a shame we can't use Perl Template Toolkit because it
would be ideal here.
There are all kinds of questions that aren't answered such as: Should
variables be replaced recursively? How do you escape %{..} if you
don't want it to be replaced? Should we allow loops or similar
constructs? Existing template systems solve these kinds of problems
already.
Anyway ...
+let var_re = PCRE.compile "%{([^}]+)}"
Are we planning to allow a completely free choice for variable names,
or could we limit this regexp to only matching ASCII alphanumeric +
underscore?
+let check_variable var =
+ String.iter (
+ function
+ | '0'..'9'
+ | 'a'..'z'
+ | 'A'..'Z'
+ | '_'
+ | '-' -> ()
+ | _ -> raise (Invalid_variable var)
+ ) var
... and then this function would presumably go away.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW