[stringtemplate-interest] Issues using first and rest

Simon May simon_may at bridleway.freeserve.co.uk
Thu Sep 28 10:19:01 PDT 2006


Hi I am currently using ST.net v2.3b5. A great piece of software by the way.

I have run into an issue with the following (extracts only shown). I am not
sure if this is a bug or I have not constructed the template correctly. I
have tried a number of variants. The attribute view.ColumnNames returns an
array of strings (names).

createview(view) ::= <<


AS
<view:selectlist();seperator=",\r\n">


>>

selectlist() ::= <<
<first(it.ColumnNames):{p | SELECT  <p>}>
<rest(it.ColumnNames):{p |         <p>}>
>>

Generates:
CREATE VIEW [dbo].[AccountEntryView](
AS
SELECT  JournalType
        CreditAmountDebitAmountReferenceClientKeyAccountNameCodeId



However

createview(view) ::= <<


AS
<first(view.ColumnNames):{p | SELECT  <p>,}>
<rest(view.ColumnNames):{p |         <p>};separator=",\r\n">


>>

Generates:

CREATE VIEW [dbo].[AccountEntryView](
AS
SELECT  JournalType,
        CreditAmount,
        DebitAmount,
        Reference,
        ClientKey,
        AccountName,
        Code,

Which is the desired result. However would generate incorrect code if there
were only one column name. I would like to do similar things as the
generator developed but it seems to me that the first and rest operators are
not working as intended. Perhaps someone can help me get this right.

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20060928/80be2ec3/attachment.html 


More information about the stringtemplate-interest mailing list