AST Haxe / HXML

5 views
Skip to first unread message

Sylvain MOUQUET

unread,
Oct 19, 2009, 4:46:35 AM10/19/09
to Eclihx[dev]
Hi,

A source code represents the visual part of the code it follows the
lexical and syntaxic grammar of a language. But the problem is it's
not structural, it's possible to get a source file in only one line
(without space) or the fields are dispatched before each method. The
editor must convert the source file in an abstract structure called
AST. An AST or Abstract syntax tree (http://en.wikipedia.org/wiki/
Abstract_syntax_tree - http://www.eclipse.org/jdt/ui/astview/view.gif)
"is a tree representation of the abstract (simplified) syntactic
structure of source code written in a certain programming language."

The AST is the core of the text editor, it must be verify optimized. I
have taken a look in the haxe source for showing how it works in the
haxe compiler. It uses a ocaml parser and generates a ocaml ast. Why
not transform the ocaml code result in java code ? The performance
will be very bad and the ocaml is not easy to learn. I prefer use a
java tree.

With the AST we will must to be able to develop the refactoring, the
classpath libraries resolver, the content assist, and more...

François Rey

unread,
Oct 19, 2009, 7:47:36 AM10/19/09
to eclih...@googlegroups.com
On Monday 19 October 2009 10:46:35 Sylvain MOUQUET wrote:
> The AST is the core of the text editor, it must be verify optimized. I
> have taken a look in the haxe source for showing how it works in the
> haxe compiler. It uses a ocaml parser and generates a ocaml ast. Why
> not transform the ocaml code result in java code ? The performance
> will be very bad and the ocaml is not easy to learn. I prefer use a
> java tree.
I do follow you there. Did you have a look at my post on the haxe mailing list
and haxe forum regarding the use of Ocaml-Java to have an haxe compiler run in
java?
http://haxe.org/forum/thread/648
http://lists.motion-twin.com/pipermail/haxe/2009-October/030528.html

> With the AST we will must to be able to develop the refactoring, the
> classpath libraries resolver, the content assist, and more...
Those are things that the IMP project can also help with
http://www.eclipse.org/imp/
See my comment on issue 34:
http://code.google.com/p/eclihx/issues/detail?id=34#c2

Whichever option is chosen significant effort would be required.
IMHO such undertaking should reuse/collaborate as much as possible with the
haxe compiler because it's the only implementation (unlike java which has
specs, compliance suite, etc.). Otherwise much time will be spent duplicating
what the compiler already does. Which is why I would favor the option of
integration the ocaml compiler in java, with the added bonus of incremental
compilation in the background. I would love to work on this but I don't have
the time nor sufficient motivations cause I've got other priorities. Such
project could be a great topic of research for those studying compiler
technologies.

Sylvain MOUQUET

unread,
Oct 19, 2009, 2:37:08 PM10/19/09
to Eclihx[dev]
I have seen your post in the official forum but there is not response
yet. I have learn OCaml at school but i am a novice, i am not able to
use the haxe parser. Actually i don't understand all the source code
of Haxe, Ocaml is a particular language...

I have tried IMP and ANTLR but i dislike it's very complex. I prefer a
little and powerful tool even if we must re-code some parts.

My goal is not to developp a compiler we will use the haxe compiler
but we need an AST and we are not able to use the AST of the haxe
compiler. In conclusion, we need a little and easy-to-use parser and
we will need to developp the Haxe AST.
Today i have used the JAVACC and i have begun to generate the Haxe
grammar language from the haxe grammar Gold version and next i will
see for developp the AST and a plugin like java version (if i have the
freetime...)




On 19 oct, 13:47, François Rey <fmj...@gmail.com> wrote:
> On Monday 19 October 2009 10:46:35 Sylvain MOUQUET wrote:> The AST is the core of the text editor, it must be verify optimized. I
> > have taken a look in the haxe source for showing how it works in the
> > haxe compiler. It uses a ocaml parser and generates a ocaml ast. Why
> > not transform the ocaml code result in java code ? The performance
> > will be very bad and the ocaml is not easy to learn. I prefer use a
> > java tree.
>
> I do follow you there. Did you have a look at my post on the haxe mailing list
> and haxe forum regarding the use of Ocaml-Java to have an haxe compiler run in
> java?http://haxe.org/forum/thread/648http://lists.motion-twin.com/pipermail/haxe/2009-October/030528.html> With the AST we will must to be able to develop the refactoring, the
> > classpath libraries resolver, the content assist, and more...
>
> Those are things that the IMP project can also help withhttp://www.eclipse.org/imp/

François Rey

unread,
Oct 23, 2009, 2:11:06 PM10/23/09
to eclih...@googlegroups.com
On Monday 19 October 2009 20:37:08 Sylvain MOUQUET wrote:
> I have seen your post in the official forum but there is not response
> yet. I have learn OCaml at school but i am a novice, i am not able to
> use the haxe parser. Actually i don't understand all the source code
> of Haxe, Ocaml is a particular language...
Can't blame you for that, I have no knowledge of OCaml at all.

> I have tried IMP and ANTLR but i dislike it's very complex. I prefer a
> little and powerful tool even if we must re-code some parts.
> My goal is not to developp a compiler we will use the haxe compiler
> but we need an AST and we are not able to use the AST of the haxe
> compiler.
Just one precision for whoever else is listening: the fact both of us have
decided not to try this path does not mean it's not possible to reuse the AST
of the haxe compiler. Someone else just need the guts and time to experiment
this path, which I think would be a better solution than a custom parser. If I
were to start on this I would first try, as suggested in the mailing list, to
run the haxe compiler in java without even trying to understand OCaml. Then
I'll find out how to talk to OCaml objects from java. The AST in haxe compiler
is already well identified as it's part of the API for new target
implementation. I would request help from haxe creator because you can be sure
the haxe compiler would have to be modified to be more usable in the context
of a jave ide, e.g. hooks for driving the parsing and collecting errors, etc.

> In conclusion, we need a little and easy-to-use parser and
> we will need to developp the Haxe AST.
> Today i have used the JAVACC and i have begun to generate the Haxe
> grammar language from the haxe grammar Gold version and next i will
> see for developp the AST and a plugin like java version (if i have the
> freetime...)

Wishing you the best!

I spent a bit of time with xtext but not enough to have something usable for
hxml. However I'm happy with xtext and plan to spend a more time on this. I
think Guice and a better designed grammar will go a long way resolving the
issues you have talked about (better error messages, auto-complete).

Reply all
Reply to author
Forward
0 new messages