hxbison

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

hxbison

Gamehaxe
Hi,

I have done a little experimenting with bison (yacc-like) parser generator  
for haxe.

http://code.google.com/p/hxbison/

This is mainly a "skeleton" file for bison.
The skeleton template language (m4) was quite hard to get into
and I'm no expert, but it got the job pretty much done. I guess
it deserves some respect because it was possible to customise the
system to generate a completely new language output from the standard
bison executable.  (When I say completely new, I actually based
it in the Java target). I did not create an automatic lexer generator,
but there is an example lexer that does a few things.
The dynamic and garbage collection aspects of haxe make it
an extremely good language to write the parser actions in.


Hugh

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: hxbison

Lee Sylvester
Hey Hugh,

Sounds excellent.  I'll definitely be taking a look at that :-)  Thanks for
sharing.

Lee


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Gamehaxe
Sent: 02 November 2011 14:52
To: The haXe compiler list
Subject: [haXe] hxbison

Hi,

I have done a little experimenting with bison (yacc-like) parser generator
for haxe.

http://code.google.com/p/hxbison/

This is mainly a "skeleton" file for bison.
The skeleton template language (m4) was quite hard to get into and I'm no
expert, but it got the job pretty much done. I guess it deserves some
respect because it was possible to customise the system to generate a
completely new language output from the standard bison executable.  (When I
say completely new, I actually based it in the Java target). I did not
create an automatic lexer generator, but there is an example lexer that does
a few things.
The dynamic and garbage collection aspects of haxe make it an extremely good
language to write the parser actions in.


Hugh

--
haXe - an open source web programming language http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxbison

Nicolas Cannasse
In reply to this post by Gamehaxe
Le 02/11/2011 15:52, Gamehaxe a écrit :
> Hi,
>
> I have done a little experimenting with bison (yacc-like) parser
> generator for haxe.
>
> http://code.google.com/p/hxbison/

Looks nice, but I would prefer to be able to directly write
lexers/parsers in haXe.

I did already some work for NekoML which has both a lexer library and
LL(k) stream parsers, I guess this could be easily ported to native haXe
and you could generate all the stub code using macros :

Lexer :

MyLexer.build(switch(string) {
case ~/[0-9]+/: TInt(Std.parseInt(lexeme));
case ~/[A-Za-z][A-Za-z0-9]*/: TIdent(Lexeme)
case ~/[+-*\/]/: TOp(lexeme);
default: throw "Invalid char "+lexeme;
});

Parser :

MyParser.build(switch(stream) {
case TIdent(x),TOp(op),TIdent(y): ...
case TInt(i): ...
default:
});

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxbison

laurence taylor
I'm still tinkering with OMeta. One version being a direct port, the other abusing parser combinators to see if I can derive the same functionality. The first has fallen with left recursive rules at present, and with the second I'm working on the bootstrap compiler. It's not a difficult port really, but I'm not 100% how to integrate it with haxe.

The choices so far:
1) full haxe code generation.
2) hxscript runtime parser/compiler generation.
3) compile time macro generation.

I rather like the idea of writing ometa ( left recursive parsing expression grammars )  programs for describing data parsers / expression generators. If I can pack it as a combinator library, I think that covers a lot of ground.

regards,
Laurence

On Wed, Nov 2, 2011 at 6:33 PM, Nicolas Cannasse <[hidden email]> wrote:
Le 02/11/2011 15:52, Gamehaxe a écrit :

Hi,

I have done a little experimenting with bison (yacc-like) parser
generator for haxe.

http://code.google.com/p/hxbison/

Looks nice, but I would prefer to be able to directly write lexers/parsers in haXe.

I did already some work for NekoML which has both a lexer library and LL(k) stream parsers, I guess this could be easily ported to native haXe and you could generate all the stub code using macros :

Lexer :

MyLexer.build(switch(string) {
case ~/[0-9]+/: TInt(Std.parseInt(lexeme));
case ~/[A-Za-z][A-Za-z0-9]*/: TIdent(Lexeme)
case ~/[+-*\/]/: TOp(lexeme);
default: throw "Invalid char "+lexeme;
});

Parser :

MyParser.build(switch(stream) {
case TIdent(x),TOp(op),TIdent(y): ...
case TInt(i): ...
default:
});

Best,
Nicolas


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org