项目作者: Michocio

项目描述 :
Using the LR method
高级语言: Prolog
项目地址: git://github.com/Michocio/Syntax_analysis.git
创建时间: 2017-09-20T16:02:54Z
项目社区:https://github.com/Michocio/Syntax_analysis

开源协议:

下载


Syntax analyser

For given finite grammar creates LR automata. Using that automata it checks if given word is accepted by particular grammar. When for given grammar, building LR automata isn’t possible, program gives kind of conflict that occurs in grammar (SHIFT-REDUCE, REDUCE-REDUCE).

Code created for “Programming languages ​​and paradigms” on 3rd year of my CS studies at University of Warsaw.

Main predicates definied:

  • createLR(+Gramamar, -Automata, -Info)
    For given grammar creates LR(0) automata. In case of success parameter Info is set to yes, otherwise it contains cause of conflict.

  • accept(+Automata, +Word)
    Success when Word is accepted by Automata.

Format of grammar defining:

gramatyka(’E’, [prod(’E’, [[nt(’E’),+,nt(’T’)], [nt(’T’)]]),
prod(’T’, [[id], [’(’, nt(’E’), ’)’]]) ]).

what is equal to:

E -> E + T | T

T -> id | ( E )