https://github.com/derdon/menhir-example
This is OCaml code which uses the libraries menhir (http://cristal.inria.fr/~fpottier/menhir/) and the Batteries (http://batteries.forge.ocamlcore.org). After it is compiled, it can be used to parse a file which contains arithmetic expressions.
https://github.com/derdon/menhir-example
Last synced: 2 months ago
JSON representation
This is OCaml code which uses the libraries menhir (http://cristal.inria.fr/~fpottier/menhir/) and the Batteries (http://batteries.forge.ocamlcore.org). After it is compiled, it can be used to parse a file which contains arithmetic expressions.
- Host: GitHub
- URL: https://github.com/derdon/menhir-example
- Owner: derdon
- License: wtfpl
- Created: 2010-06-28T23:51:49.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2019-04-01T03:22:24.000Z (almost 7 years ago)
- Last Synced: 2024-08-04T01:28:47.579Z (over 1 year ago)
- Language: OCaml
- Homepage:
- Size: 110 KB
- Stars: 52
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: COPYING
Awesome Lists containing this project
- awesome-list - menhir-example
README
About
=====
NOTE: This code is all *example* code. It is targeted to developers; read it
and learn from it!
This example should be seen as an extension to the already existing menhir
examples (accessible through the directory "demo" in the source code of menhir).
To write this code, I used the example demos/calc from menhir's source code.
In the files lexer.mll and parser.mly I added comments for my own modifications
so that the reader of the source code can distinguish between code from INRIA
and code added by me.
A testfile is attached to avoid misunderstandings with the required file format.
Dependencies / Requirements
===========================
- OCaml_, tested with version 3.11.2
- Batteries_, tested with version 1.1.0-1
- menhir_ , tested with version 20090505
File format
===========
Every expression must end with a semicolon (;). Whitespace, tabulators and
newlines are ignored.
How to compile
==============
``ocamlbuild calc.native``
How to use
==========
``./calc.native [filename]``
This command will print a list of results, represented as an OCaml list.
.. _OCaml: http://caml.inria.fr
.. _Batteries: http://batteries.forge.ocamlcore.org/
.. _menhir: http://cristal.inria.fr/~fpottier/menhir/