编程语言+ XML + XSL =编译器? [英] Programming language + XML + XSL = compiler ?

查看:81
本文介绍了编程语言+ XML + XSL =编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们


这边的新人。这篇文章可能是重复的,我想我上次打了




我最近开始使用XML和XSL而且我''我对

印象非常深刻。我的用途本质上是非网络的。事实上,我正在用XML中的高级规范编写一个

排序的编译器,最终生成VHDL。


我''我们做了以下观察:


1.给定纯源代码(例如:Java,C ++),可以用XML生成一个抽象的

语法树。

2. XML也适用于符号表和中间符号。

3. XSLT可以对所述中间形式进行强大的转换。

4 XSL可以生成纯文本。


我想知道在XML / XSL中使用语言实现

a的编译器需要什么。更具体地说,是否有任何基于XSL或
的XML系统可以帮助将纯源扫描到XML中,以便转换可以开始转换?语法可以标记为

EBNF。这可能过于乐观,因为这个过程需要

LL / LALR等知识。


另一种方法是使用标准扫描仪/解析器

生成器,它有自己的(不可互换的)EBNF并且有动作

代码生成标记的标记,给你一个XML格式的AST。


我的问题:

1. EBNF有没有合适的XML格式?

2.是否有任何工具/ XSL扩展可以做以上?

3.您对整个想法有何看法?


祝你好运,

Richard Brady

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

推荐答案

rn ***** @ gmail。 com 写道:
我想知道如何在XML / XSL中实现给定语言的编译器。


请记住,XSL是一个纯粹的功能语言。这可能使一些严重的编译器想要执行的操作变得困难。


但是,是的,一个基本的老式的替换 - 用 - 等价代码

转换应该是可能的。这不是我将选择进行的工具集 - 自定义数据结构可能比尝试用XML模拟所有内容更有效率 - b $ b - 但是如果你是在寻找一个教学练习,那可能是一件有趣的尝试。


我是你,我会从一种语言开始,语法比Java或C ++更简单,并使用它来建立你的框架和

了解问题(包括性能和内存空间)。那么,如果

你仍然有野心勃勃,那就去吧。


(就个人而言,为了写作,我已经停止编写编译器了

编译器。我宁愿等到我有理由确定有什么东西

我会比现有的替代方案做得更好。)


更具体地说,是否有任何基于XSL或XML的系统可以帮助将纯源扫描到XML中,以便可以开始转换?语法可以用标记的EBNF提供。这可能过于乐观了,因为这个过程需要知识LL / LALR等。

另一种方法是使用你的标准扫描仪/解析器
生成器''自己的(不可互换的)EBNF并且行动
代码生成标记的令牌,为您提供XML格式的AST。

我的问题:
1.有没有合适的XML谢谢EBNF?
2.上面是否有任何工具/ XSL扩展?
3.您对整个想法有何看法?

致以最诚挚的问候,
Richard Brady
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




*****@gmail.com 写道:

rn*****@gmail.com wrote:
3. XSLT可以对所述中间形式进行强大的转换。
3. XSLT can do powerful transformations of said internediate forms.



IMHE,XSLT无法做到强大,对于有趣的强大价值观。它是b $ b确实是庞大而简单的非常好,非常适合文本

处理文本块。如果你尝试做任何涉及

语义的事情,它会开始变平。



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.


rn ***** @ gmail.com 写道:
rn*****@gmail.com wrote:
我想知道它需要什么在XML / XSL中实现给定语言的编译器。更具体地说,是否有任何XSL或


这已在5年前建议

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


以及去年年底的comp.compilers。

Google forxml as intermediate representation

3.您对整个想法有何看法?
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?




教学编译器构造可能是一个区域

这个想法可能是有用。但在现实生活中,

我不喜欢用XML编写我的源代码。



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.


这篇关于编程语言+ XML + XSL =编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆