Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Define parser and printer consistently
       [not found] <20101209110003.3C0B3BBAF@yquem.inria.fr>
@ 2010-12-09 11:11 ` CUOQ Pascal
  0 siblings, 0 replies; 2+ messages in thread
From: CUOQ Pascal @ 2010-12-09 11:11 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]


>I'm going to define a parser and a printer for a simple grammar.
>Is there a way to define both of them in a single construct using some 
>existing OCaml tool?
>
>For example, I have a keyword "function". The usual parser would contain 
>a mapping like:
>"function" -> `Function
>and the straightforward printer would do:
>`Function -> "function"
>
>What is the best way to combine these definitions, so that duplication 
>would be minimized?

Take a look at Boomerang: http://www.seas.upenn.edu/~harmony/

>From the overview:

Boomerang is a programming language for writing lenses—well-behaved bidirectional transformations—that operate on ad-hoc, textual data formats. Every lens program, when read from left to right, describes a function that maps an input to an output; when read from right to left, the very same program describes a "backwards" function that maps a modified output, together with the original input, back to a modified input.

Lenses have been used to solve problems across a wide range of areas in computing including: [...] in parsers and pretty printers

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 3143 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Define parser and printer consistently
@ 2010-12-09  4:47 Dawid Toton
  0 siblings, 0 replies; 2+ messages in thread
From: Dawid Toton @ 2010-12-09  4:47 UTC (permalink / raw)
  To: caml-list

I'm going to define a parser and a printer for a simple grammar.
Is there a way to define both of them in a single construct using some 
existing OCaml tool?

For example, I have a keyword "function". The usual parser would contain 
a mapping like:
"function" -> `Function
and the straightforward printer would do:
`Function -> "function"

What is the best way to combine these definitions, so that duplication 
would be minimized?
To be precise, avoiding duplication is not exactly what I need. I'm 
looking for something that would prevent making inconsistent changes to 
the parser and the printer.

Dawid


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-09 11:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20101209110003.3C0B3BBAF@yquem.inria.fr>
2010-12-09 11:11 ` Define parser and printer consistently CUOQ Pascal
2010-12-09  4:47 Dawid Toton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox