[stringtemplate-interest] map syntax

Terence Parr parrt at cs.usfca.edu
Thu Dec 10 16:52:01 PST 2009


Hi, wondering about syntax for applying template to an expr.  To insert a template, we do

<template()>

to pass a single arg, we can do

<template(expr)>

Or, in v3, we can do

<expr:template()>

In v4, I was proposing no parens:

<expr:template>

but now I'm wondering if that's correct.  I would like to be able to store a template into an attribute and then apply it.

foo(names, t={x | hi <x>}) ::= "<names:t>"

But that is what i use for when t is a literal template name not an attr.  Perhaps we leave it as template() for the literal name.

I'm also adding syntax to evaluate an expression to get a template name like this:

<expr:(e)>             convert e to a string template name and apply to expr

but maybe that should be:

<expr:(e)()>

Elsewhere I use <(e)()> syntax to eval e to a string and then invoke the template so it'd be more consistent.

<expr:template()>
<expr:attribute>
<expr:(expr)()>
<expr:{arg | ...}>

Any thoughts on syntax/semantics?

Ter


More information about the stringtemplate-interest mailing list