[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Server Side Includes/HTML + scripting
Hi James,
Back in 99 I was working with Etienne on duplicating a web scripting
language that was created in 95. The company had gone out of business.
The language was based on lisp. The source including the grammar is
available at http://www.peacekeeper.com/temp/opensmx.zip
The language was fairly full-featured for its day but ultimately it was
easier to use other more popular languages. One of these days I will
finish it for posterity's sake.
A few samples are below.
My ip is %client-ip%.
output "My ip is 127.0.0.1."
2 + 2 + 3 = %add(2,2,3)
output "2 + 2 + 3 = 7"
%set(a,red)
%if((%equal(%a%,red),true,false)
output "true"
There is no <% %> in the language. It is fully meshed with the text.
Everything is treated as a string.
I can't tell you anything technical about the SableCC side of the
language. But I can answer questions regarding its usage.
Thanks
-Noah
James Buchanan wrote:
>
> Hi,
>
> Can someone please give me some tips on how I might implement a parser
> for a program that processes server side includes (SSI) or a mini
> language that can be interspersed throughout an HTML file?
>
> E.g. for SSI:
>
> <!--#exec cmd="/bin/foo"-->
> <p>Hi. Document root is: <!--#var name="$DOCUMENT_ROOT"--></p>
>
> <!--#if expr="$foo == $bar" -->
> <h3>My homepage</h3>
> <!--#else -->
> <h3>My new homepage</h3>
> <!--#endif -->
>
> ... or very similar to this.
>
> For something like PHP or ASP:
>
> <%
> statments...
> %>
>
> <%= var %> ; Direct output
>
> <% if foo.length() > 0 then %>
> <b>foo's length is greater than 0!</b>
> <% endif %>
>
> The programming commands can mix in with the HTML by having the
> statments inside special tags the parser picks up. It would need to
> associate the next block of HTML with the tag if it's a conditional,
> otherwise it gets sent out after processing the command tag(s).
>
> I'm not exactly sure how I could do this. The nodes that get built after
> the parser builds the parse tree might have a link to a node that holds
> HTML to output. It would need to be able to find the extra nodes that
> it wants to end if statements and such, so it can skip elseif parts.
> Similar for looping constructs.
>
> Node: <% stuff %>
> HTMLNode (just print it out)
> Node: <%= varname %>
> HTMLNode (just print it out)
> Node: <% morestuff %>
>
> Any ideas for a grammar that I can make with SableCC?
>
> Thanks,
> James
--
***********************************************************
Noah Mapstead - noah@peacekeeper.com
Chief Technology Officer
Peacekeeper Enterprises, LLC http://www.peacekeeper.com
Check out our new site: http://www.donationtree.com
160+ stores rebate a portion of each purchase to a charity, school, or
college savings plan.