* [Caml-list] Genlex - and which parser?
@ 2002-09-01 16:53 Oliver Bandel
2002-09-01 22:18 ` Remi VANICAT
0 siblings, 1 reply; 5+ messages in thread
From: Oliver Bandel @ 2002-09-01 16:53 UTC (permalink / raw)
To: caml-list
Hello,
I recently (today) experimented with the Genlex-module.
It seems to be very very easy to lex code.
(But some things are predefined, what has advantages and
disadvantages, I think, but doesn't matter here.)
Which parser can be used together with Genlex?
Is it ocamlyacc? Or others?
Or do I have to write most code for parsing by my own?
Are there any examples in using the Genlex-module?
Seems to be the easiest lexer I found.
If there would be a Genpare-module, this would be
the easiest way for writing little-language's parsers.
So, any hints are welcome.
Ciao,
Oliver
--
IT nach Hause telefonieren...
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Genlex - and which parser?
2002-09-01 16:53 [Caml-list] Genlex - and which parser? Oliver Bandel
@ 2002-09-01 22:18 ` Remi VANICAT
2002-09-02 12:35 ` Oliver Bandel
0 siblings, 1 reply; 5+ messages in thread
From: Remi VANICAT @ 2002-09-01 22:18 UTC (permalink / raw)
To: caml-list
Oliver Bandel <oliver@first.in-berlin.de> writes:
> Hello,
>
> I recently (today) experimented with the Genlex-module.
> It seems to be very very easy to lex code.
>
> (But some things are predefined, what has advantages and
> disadvantages, I think, but doesn't matter here.)
>
> Which parser can be used together with Genlex?
> Is it ocamlyacc? Or others?
ocamlyacc goes with ocamllex. parser that goes with Genlex are stream
parser, describe in chapter 2 of the Camlp4 reference manual and
chapter 2 of the Camlp4 tutorial
--
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Genlex - and which parser?
2002-09-01 22:18 ` Remi VANICAT
@ 2002-09-02 12:35 ` Oliver Bandel
2002-09-02 13:53 ` Daniel de Rauglaudre
2002-09-02 13:59 ` Remi VANICAT
0 siblings, 2 replies; 5+ messages in thread
From: Oliver Bandel @ 2002-09-02 12:35 UTC (permalink / raw)
To: Remi VANICAT; +Cc: caml-list
Hello Rémi,
On Mon, 2 Sep 2002, Remi VANICAT wrote:
> Oliver Bandel <oliver@first.in-berlin.de> writes:
[...]
> > Which parser can be used together with Genlex?
> > Is it ocamlyacc? Or others?
>
> ocamlyacc goes with ocamllex. parser that goes with Genlex are stream
> parser, describe in chapter 2 of the Camlp4 reference manual and
> chapter 2 of the Camlp4 tutorial
Hmhhh in the campl4-tutorial/-reference they explain an other
Lexer (Plexer). I think it's similar.
Will Genlex not be used? Or is Plexer based on Genlex?
Any way, thanks for your hint.
Some additional words:
In the camlp4-tutorial there is an example for programming a
simple calculator.
I didn't expect to get a working solution/example on page 9
of the tutorial.
That's great!
I have looked for such tools for many years and now I have found it. :)
Again, as I said about OCaml, I can say about Camlp4, that
it's a great piece of work, what the developpers/researchers
have done in providing such a great language and tools.
If I think about how to write such stuff with lex/yacc
in C, and then look at the power of Ocaml wow, then I more
and more see that writing C (and it's followers) are the middle-
ages of programming.
Ciao,
Oliver
P.S.: I think it's now time to write DSLs. :)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Genlex - and which parser?
2002-09-02 12:35 ` Oliver Bandel
@ 2002-09-02 13:53 ` Daniel de Rauglaudre
2002-09-02 13:59 ` Remi VANICAT
1 sibling, 0 replies; 5+ messages in thread
From: Daniel de Rauglaudre @ 2002-09-02 13:53 UTC (permalink / raw)
To: caml-list
Hi,
On Mon, Sep 02, 2002 at 02:35:32PM +0200, Oliver Bandel wrote:
> Hmhhh in the campl4-tutorial/-reference they explain an other
> Lexer (Plexer). I think it's similar.
> Will Genlex not be used? Or is Plexer based on Genlex?
No: the lexer Plexer of Camlp4 does not use Genlex. Genlex is for
simple lexers and does not suit for lexing OCaml and the extensions
that Camlp4 need (e.g. quotations).
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Genlex - and which parser?
2002-09-02 12:35 ` Oliver Bandel
2002-09-02 13:53 ` Daniel de Rauglaudre
@ 2002-09-02 13:59 ` Remi VANICAT
1 sibling, 0 replies; 5+ messages in thread
From: Remi VANICAT @ 2002-09-02 13:59 UTC (permalink / raw)
To: Oliver Bandel; +Cc: Remi VANICAT, caml-list
Oliver Bandel <oliver@first.in-berlin.de> writes:
> Hello Rémi,
>
>
> On Mon, 2 Sep 2002, Remi VANICAT wrote:
>
>> Oliver Bandel <oliver@first.in-berlin.de> writes:
> [...]
>> > Which parser can be used together with Genlex?
>> > Is it ocamlyacc? Or others?
>>
>> ocamlyacc goes with ocamllex. parser that goes with Genlex are stream
>> parser, describe in chapter 2 of the Camlp4 reference manual and
>> chapter 2 of the Camlp4 tutorial
>
> Hmhhh in the campl4-tutorial/-reference they explain an other
> Lexer (Plexer). I think it's similar.
> Will Genlex not be used? Or is Plexer based on Genlex?
>
> Any way, thanks for your hint.
Well, there is to type of parser that you can read about in the camlp4
documentation :
those of the chapter 2 (Streams and parsers) which correspond to the
Genlex lexer, and those of the Camlp4 Grammar module, which use
Plexer.
Here an example of the Stream parser :
open Genlex;;
let lexer = make_lexer ["+"; "-"; "("; ")"];;
let rec simple_calc = parser
| [< v = simple_value ; rest >] ->
simple_calc_rest v rest
and simple_value = parser
| [< 'Int i >] -> i
| [< 'Kwd "("; v = simple_calc; 'Kwd ")" >] -> v
and simple_calc_rest v1 = parser
| [< 'Kwd "+"; v2 = simple_calc >] -> v1 + v2
| [< 'Kwd "-"; v2 = simple_calc >] -> v1 - v2
| [< >] -> v1;;
let make_calc () =
let l = read_line () in
let st = Stream.of_string l in
let le = lexer st in
simple_calc le;;
(notice that this parser is buggy : it evaluated 3 - 1 + 3 as -1 when
it should answer 5).
--
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-09-02 13:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-01 16:53 [Caml-list] Genlex - and which parser? Oliver Bandel
2002-09-01 22:18 ` Remi VANICAT
2002-09-02 12:35 ` Oliver Bandel
2002-09-02 13:53 ` Daniel de Rauglaudre
2002-09-02 13:59 ` Remi VANICAT
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).