Institute of Computer Science
  1. Courses
  2. 2019/20 spring
  3. Automata, Languages and Compilers (LTAT.03.006)
ET
Log in

Automata, Languages and Compilers 2019/20 spring

  • Üldinfo
  • Eksami näidised
  • Kava
    • 1. Soojendus
    • 2. Regulaaravaldised
    • 3. Olekumasinad
    • 4. Avaldise struktuur
    • 5. Grammatikad ja lekser
    • 6. Käsitsi parsimine
    • 7. ANTLRiga töötamine
    • 8. Interpretaator
    • 9. Kompilaator
  • Bitbucket
  • Moodle
  • Fleep!

ANTLR-i IDE plugina paigaldamine

ANTLR-it on kõige mugavam kasutada mõne IDE plugina kujul. Õnneks on vastav plugin olemas kõigi populaarsete Java IDE-de jaoks.

IntelliJ

Vali "File" menüüst "Settings", siis "IDE Settings" osast "Plugins", klõpsa nuppu "Browser repositories" ja vali "ANTLR v4 grammar plugin". Klõpsa install ja taaskäivita IDE.

Täpsem info siit: https://github.com/antlr/intellij-plugin-v4

Eclipse

Plugina koduleht on siin: https://github.com/jknack/antlr4ide.

Hetkel (aprill 2016) ei saa ametlike juhiste järgi seda pluginat viimasele Eclipse'ile paigaldada, seetõttu soovitame allolevaid samme. Eeldame, et sul on Eclipse Mars for Java Developers, aga võimalik, et samad juhised toimivad ka teiste versioonide puhul.

  1. Installi Xtext. Kuna ANTLR plugin ei tööta Xtexti viimase versiooniga, siis lae alla http://www.eclipse.org/downloads/download.php?file=/modeling/tmf/xtext/downloads/drops/2.7.3/R201411190455/tmf-xtext-Update-2.7.3.zip, vali Eclipse'is Help => Install new software => Add ... (nupp dialoogi üleval-paremal nurgas) => Archive => vali allalaetud zip fail => märgi installeerimiseks "Xtext" ja lase Eclipse'il installida. Kui Eclipse nõuab restarti, siis lase see tal teha
  2. Installi ANTLR-i plugin (vt https://github.com/jknack/antlr4ide#installation)

Paigalduse kontrollimine

Kontrollimaks kas plugina installimine õnnestus, loo mingi Java projekti alla (näiteks meie reposse kausta src/main/antlr/week7) fail nimega Avaldis.g4, ava see ning kopeeri sinna järgnev tekst:

grammar Avaldis;

avaldis
    :   avaldis '+' term
    |   avaldis '-' term
    |   term
    ;

term
    :   term '*' faktor
    |   term '/' faktor
    |   faktor
    ;

faktor
    :   '(' avaldis ')'
    |   Muutuja
    |   Konstant
    ;

Muutuja
    :   [a-zA-Z_][a-zA-Z_0-9]*
    ;

Konstant
    :    [0-9]|[1-9][0-9]+
    ;

Kui editor näitab seda teksti värviliselt, siis on tõenäoliselt paigaldus õnnestunud.

  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment