Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will write a simple parser for the object language being a simple logic programming language ( similar e . g .

In this assignment, you will write a simple parser for the "object language" being a simple logic programming language (similar e.g., to a subset of Prolog).
The parser itself has to be written using the OCaml version of Yacc.
Below is an abstract definition of the logic programming language's syntax.
You should use your learning of Prolog (Assignments 1 and 2) to write a concrete grammatical specification for the logic programming language corresponding to the abstract formulation below. The objective of the exercise is for you to define the grammar as well as the lexical tokens for your surface language. You will be evaluated on your design of the surface syntax as well as the implementation of the parser.
You may e.g., deviate from the standard Prolog syntax if you so wish (in particular, you may want to use the if-then-else construction or a generalisation of it).
You will need to represent an abstract syntax of the logic programming language as a data type in OCaml. Abstract syntax trees (terms in this data type) will be the output of your parser.
The abstract structure of a Prolog program is the following:
A program is a sequence of clauses.
A clause can either be a fact or a rule.
A fact has a head but no body. A rule has a head and a body.
The head is a single atomic formula.
A body is a sequence of atomic formulas.
An atomic formula is a k-ary predicate symbol followed by k terms.
A term is either a variable, a constant, or a k-ary function symbol with k subterms.
A goal is a sequence of atomic formulas.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions