work-site/en/parsing-upec.org

78 lines
2.6 KiB
Org Mode
Raw Normal View History

2018-09-23 01:00:59 +02:00
#+TITLE: Basic Parsing
#+LANGUAGE: en
#+ATTR_HTML: :alt in French :class lang-lifted
[[file:../fr/parsing-upec.org][file:../content/imgs/fr.png]]
#+ATTR_HTML: :alt return home :class home
[[file:home.org][file:../content/imgs/home.png]]
I taught the part of a course on formal languages which was related to
the [[http://en.wikipedia.org/wiki/Chomsky%2520hierarchy][Chomsky hierarchy]] and [[http://en.wikipedia.org/wiki/Parsing][parsing]].
#+ATTR_HTML: :alt image of Creative Commons Attribution Alone licence :class ccby
[[https://en.wikipedia.org/wiki/Creative_Commons_license][file:../content/imgs/ccby.png]]
The materials of my course are distributed under the [[https://en.wikipedia.org/wiki/Creative_Commons_license][Creative Commons
Attribution Alone licence]].
* Slides
The slides for this course are available [[file:../content/courses/parsing-upec/parsing.pdf][here]] (in French).
* Practical assignment
The exercises for the practical assignment (in French) can be
downloaded [[file:../content/courses/parsing-upec/parsing-tp.pdf][here]].
* Source code
In this course I show a simple interpreter for a language of
variable assignments. The variables can either be strings or integer
numbers. A program in this language may look as follows:
#+BEGIN_SRC
String var1 = "hello world 1 + 2";
int var2 = 1 - (2 + 3);
int var3 = 4 + var2;
#+END_SRC
[[file:../content/courses/parsing-upec/parsing.zip][This archive]] contains the complete source code of the interpreter as
well as several example programs.
To build the project, run the following commands:
#+BEGIN_SRC
jflex arith.flex
jacc arith.jacc
javac ArithEval.java
#+END_SRC
The following command runs just the scanner on the first example:
#+BEGIN_SRC
java Yylex examples/example1.duck
#+END_SRC
The following command runs the interpreter on the first example:
#+BEGIN_SRC
java ArithEval examples/example1.duck
#+END_SRC
* Toolchain
The project relies on [[http://jflex.de/download.html][JFlex]] scanner generator and [[http://web.cecs.pdx.edu/~mpj/jacc/][Jacc]] parser
generator. Both tools generate Java code. [[file:../content/courses/parsing-upec/parsing-workflow.pdf][Here]] is a short overview
of a typical workflow.
This toolchain was suggested by [[http://lacl.univ-paris12.fr/gava/actuel.htm][Frédéric Gava]] (section Parsing de
fichiers en Java). This page also contains other slides about
parsing.
* Local Variables :noexport:
# Local Variables:
# org-link-file-path-type: relative
# eval: (auto-fill-mode)
# ispell-local-dictionary: "en"
# End: