[stringtemplate-interest] proposed "ignore newlines" template syntax
Collin Fagan
collin.fagan at gmail.com
Mon Apr 4 11:02:44 PDT 2011
Will using "" require people to escape a single " in a template?
t() ::= ""
System.out.println(\"hi\");
""
Collin
On Mon, Apr 4, 2011 at 12:32 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> true, but it seems like the better syntax. Plus emacs is your friend ;)
>
> Ter
> On Apr 4, 2011, at 10:27 AM, Sam Harwell wrote:
>
> > Using ""..."" makes it very tedious to change a template from << >> to a
> > non-newline template because the escape character changes.
> >
> > Sam
> >
> > -----Original Message-----
> > From: stringtemplate-interest-bounces at antlr.org
> > [mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Terence
> Parr
> > Sent: Monday, April 04, 2011 12:00 PM
> > To: Collin Fagan
> > Cc: stringtemplate-interest List
> > Subject: Re: [stringtemplate-interest] proposed "ignore newlines"
> template
> > syntax
> >
> >
> > On Apr 4, 2011, at 9:25 AM, Collin Fagan wrote:
> >
> >> When you declare a single line template you can use " so it does feel
> > consistent to use the " symbol again. Would using a different symbol like
> '
> > require one to escape the new symbol in our templates? That might be a
> good
> > reason to not introduce a new character and use "" or """.
> >
> > Yeah,I was thinking the same thing on the way to work. double quoted
> > strings "..." means single-line template at the moment... double double
> > quoted strings should therefore be used I guess. ok, I buy that.
> >
> > t() ::= ""
> > <if(x)>
> > saldf;jalk;sdfj
> > <endif>
> > ...
> > ""
> >
> > Looks fine.
> >
> > Ter
> >>
> >> Collin
> >>
> >> On Mon, Apr 4, 2011 at 10:31 AM, Terence Parr <parrt at cs.usfca.edu>
> wrote:
> >> Hi guys, thanks for the response...
> >>
> >> I was thinking '''...''' myself like python. I like the suggestions
> about
> > future flexibility but after 10 years this is the first change we've
> needed.
> > Contrast this with lots of antlr grammar rule options.
> >>
> >> maybe triple double quotes to reuse "..." symbols?
> >>
> >> t() ::= """
> >> ...
> >> """
> >>
> >> ?
> >>
> >> Ter
> >> On Apr 3, 2011, at 7:52 PM, Collin Fagan wrote:
> >>
> >>> I think it's a great idea :) Here are some alternatives for the syntax.
> > I'm not quite sure that at a glance I'd notice the difference between <<
> and
> > <<<.
> >>>
> >>> Double 'double quotes'
> >>> ""...""
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= ""
> >>> <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>> ""
> >>> Triple 'single quotes'
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>> """
> >>>
> >>> The < and > with some other symbols.
> >>> <# .. #>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <# <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>> #>
> >>>
> >>> <| ... |>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <| <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>> |>
> >>>
> >>> <@ ... @>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <@ <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>> @>
> >>>
> >>> PHP style
> >>> <?...?>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <?
> >>> <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>> ?>
> >>>
> >>> ASP style
> >>> <%...%>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <% <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>> %>
> >>>
> >>> Collin
> >>>
> >>>
> >>> On Sun, Apr 3, 2011 at 6:09 PM, Terence Parr <parrt at cs.usfca.edu>
> wrote:
> >>> Hi. There is a proposal to create special syntax that allows arbitrary
> > formatting within a template that does not result in new lines in the
> > output. This is useful when you have a really complicated template with
> IFs
> > and such that needs to generate output all on the same line. Currently,
> this
> > can be quite challenging. There's no way to read a huge template on one
> > line. Sam Harwell and I came up with a potential solution: a new
> <<<...>>>
> > triple angle bracket template that ignores newlines unless you use <\n>
> > inside.
> >>>
> >>> Here's a simple example:
> >>>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <<
> >>> <if(label)><label>=<endif><if(scope)><scope:delegateName()>.<endif><r
> >>> ule.name>(<args; separator=", ">);
> >>>>>
> >>>
> >>> it would probably be easier to read like this:
> >>>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <<< <if(label)>
> >>> <label>= <endif> <if(scope)> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>>>>>
> >>>
> >>> come to think of it, perhaps it should also ignore whitespace so that I
> > could indent the conditionals:
> >>>
> >>> ruleRef(rule,label,elementIndex,args,scope) ::= <<< <if(label)>
> >>> <label>=
> >>> <endif>
> >>> <if(scope)>
> >>> <scope:delegateName()>.
> >>> <endif>
> >>> <rule.name>(<args; separator=", ">);
> >>>>>>
> >>>
> >>> We while the syntax to be close, but still recognizable as different
> than
> > the usual <<...>>. I believe that there has been a proposal for special
> > characters at the start of the template and the addition of keyword but I
> > think a new template and closure syntax is better.
> >>>
> >>> thoughts?
> >>>
> >>> Thanks,
> >>> Ter
> >>>
> >>>
> >>> _______________________________________________
> >>> stringtemplate-interest mailing list
> >>> stringtemplate-interest at antlr.org
> >>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> >>>
> >>> _______________________________________________
> >>> stringtemplate-interest mailing list
> >>> stringtemplate-interest at antlr.org
> >>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> >>
> >>
> >
> > _______________________________________________
> > stringtemplate-interest mailing list
> > stringtemplate-interest at antlr.org
> > http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> >
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110404/05d946f3/attachment-0001.html
More information about the stringtemplate-interest
mailing list