Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Programming language + XML + XSL = compiler ?

Reply
Thread Tools

Programming language + XML + XSL = compiler ?

 
 
rnbrady@gmail.com
Guest
Posts: n/a
 
      06-23-2006
Hi folks

New around here. This post may be a duplicate, I think I bungled the
previous one.

I've recently started out with XML and XSL and I'm very impressed with
both. My use is non-web in nature. In fact, I'm writing a compiler of
sorts, from high-level spec in XML, with eventual generation of VHDL.

I've made the following observations:

1. Given pure source code (Eg:Java,C++), one could generate an abstract
syntax tree in XML.
2. XML is also apposite for symbol tables and intermediate froms.
3. XSLT can do powerful transformations of said internediate forms.
4. XSL can generate plain text.

I'm wondering wondering what it would take to implement a compiler for
a given language in XML/XSL. More specifically, are there any XSL or
XML based systems that assist in scanning pure source into XML so that
the transformations can begin? Grammar could be provided in marked-up
EBNF. This is probably over-optimistic could the process would need
knowledge of LL/LALR etc.

The alternative approach is to use your standard scanner/parser
generator with it's own (non-interchangable) EBNF and have the action
code generate tagged tokens, giving you an AST in XML.

My questions:
1. Are there any decent XML shema's for EBNF?
2. Are there any tools / XSL extensions to do the above?
3. What are your thoughts on the whole idea?

Best regards,
Richard Brady

 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      06-23-2006
wrote:
> I'm wondering wondering what it would take to implement a compiler for
> a given language in XML/XSL.


Remember, XSL is a pure functional langauge. That may make some of the
manipulations a serious compiler would want to perform difficult.

But, yes, a basic old-fashioned just-replace-with-equivalent-code
transformation ought to be possible. This is not the set of tools I
would choose to do it in -- custom data structures are likely to be much
more efficient than trying to model everything in XML -- but if you're
looking for a pedagogical exercise, it could be a fun thing to try.

Were I you, I'd start with a language that has simpler syntax and
semantics than Java or C++, and use that to establish your framework and
understand the issues (including performance and memory space). Then, if
you're still feeling ambitious, go for it.

(Personally, I've stopped writing compilers for the sake of writing
compilers. I'd rather wait until I'm reasonably sure there's something
mine will do better than any existing alternative.)



More specifically, are there any XSL or
> XML based systems that assist in scanning pure source into XML so that
> the transformations can begin? Grammar could be provided in marked-up
> EBNF. This is probably over-optimistic could the process would need
> knowledge of LL/LALR etc.
>
> The alternative approach is to use your standard scanner/parser
> generator with it's own (non-interchangable) EBNF and have the action
> code generate tagged tokens, giving you an AST in XML.
>
> My questions:
> 1. Are there any decent XML shema's for EBNF?
> 2. Are there any tools / XSL extensions to do the above?
> 3. What are your thoughts on the whole idea?
>
> Best regards,
> Richard Brady
>

 
Reply With Quote
 
 
 
 
Andy Dingley
Guest
Posts: n/a
 
      06-23-2006

wrote:

> 3. XSLT can do powerful transformations of said internediate forms.


IMHE, XSLT can't do "powerful", for interesting values of powerful. It
does "Bulky but simple" very well indeed and is excellent for text
processing with blocks of text. If you try and do anything involving
semantics though, it starts to fall flat.

 
Reply With Quote
 
=?ISO-8859-1?Q?J=FCrgen_Kahrs?=
Guest
Posts: n/a
 
      06-23-2006
wrote:

> I'm wondering wondering what it would take to implement a compiler for
> a given language in XML/XSL. More specifically, are there any XSL or


This has been suggested 5 years ago in

http://www.idealliance.org/papers/xm.../03-05-04.html

and also in comp.compilers late last year.
Google for "xml as intermediate representation"

> 3. What are your thoughts on the whole idea?


Teaching compiler construction could be an area
where this idea might be useful. But in real life,
I would _not_ like to write my source code in XML.
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      06-24-2006
Then there's always the inverse: a programming language whose syntax is
based on XML, so it can be styled by XSLT (or generated from other XML
sources by XSLT). IBM's Bean Markup Language and BML Scripting Pages,
which I was involved in some years ago, were one such example, though in
that case the language was designed for configuration and assembly of
existing Java components (and BSF scripts, also something that I helped
develop) rather than being intended as a completely stand-alone
programming environment.


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      06-24-2006
On Fri, 23 Jun 2006 23:46:38 -0400, Joe Kesselman
<keshlam-> wrote:

>Then there's always the inverse: a programming language whose syntax is
>based on XML, so it can be styled by XSLT (or generated from other XML
>sources by XSLT).


Ant

SQL DDL, as managed by the Apache Torque project

 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      06-24-2006
Hm. I don't usually think of Ant as a programming language, and I don't
think I've heard of anyone styling it, but that's an interesting
observation -- stylesheets to adapt Ant builds to different
environments, perhaps...


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
rnbrady@gmail.com
Guest
Posts: n/a
 
      06-26-2006
Hi folks

Thanks for the input. I'm not actually thinking of doing this as a
project, just curious about whether any investigation has been done on
the topic. I currently use this technique to transform digital signal
processing (DSP) algorithms specified in XML into VHDL implementations
of those algorithms.

Perhaps I'm off the mark with suggesting it for C++ or Java, but it's a
particularly interesting concept when considering higher-level
specifications such as in model driven engineering (like UML in MDA). A
large emphasis becomes interoperability/exchangability/portability of
models, but at the core of it all is transformations between models.

It's interesting because we all have different backgrounds and
therefore unique perspectives on an concept like this.

Thanks again,
Richard

 
Reply With Quote
 
Juergen Kahrs
Guest
Posts: n/a
 
      06-26-2006
wrote:

> the topic. I currently use this technique to transform digital signal
> processing (DSP) algorithms specified in XML into VHDL implementations
> of those algorithms.


Where did you get the DSP algorithms in XML ?
Is there any standard for this ?
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      06-26-2006

Joe Kesselman wrote:
> Hm. I don't usually think of Ant as a programming language,


In its limited little way, it's a declarative programming language (as
was Prolog). You can use it as a convenient dependency resolver.

> I don't think I've heard of anyone styling it,


I have an XSLT stylesheet that auto-documents Ant external targets.
Handy when I'm shipping deployment scripts to users.

I also auto-generate Ant from a vile combination of our bug tracker,
change control, and Torque repository. This generates database patch
scripts for upgrading customer databases from arbitrary start points to
new product versions.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorry for interrupt,because my mother language is not English,it maybe a little confused to read the c programming language. Zhang Yuan C Programming 6 06-14-2012 04:35 AM
writing a compiler for Monster language using C language Shravani C Programming 8 03-16-2008 09:36 PM
XML based programming language stefaan Python 13 03-22-2007 08:38 PM
Can Your Programming Language Do This? Joel on functional programming and briefly on anonymous functions! Casey Hawthorne Python 4 08-04-2006 05:23 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57