Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Languages - Grammar Write your own grammar for a programming language (The set of rules that tell you whether a sentence is correctly structured

Programming Languages - Grammar

Write your own grammar for a programming language (The set of rules that tell you whether a sentence is correctly structured is called a grammar). You will need to create a context-free grammar for your language. This grammar will need to be able to be recognized via recursive descent parsing. A recognizer is a program which says whether the expressions (sentences) in your source code are syntactically legal. A recursive descent parser is composed of a set of parsing functions, each of which derives from a rule in the grammar. Not all grammars are suitable for recursive descent parsing. Anything that is your own grammar that will work as a programming language is acceptable for an answer to this question as long as it is complete.

An Example using plain English:

sentence : nounPhrase verbPhrase PERIOD

nounPhrase : ARTICLE Adjective NOUN

verbPhrase : VERB nounPhrase

then with further modification the language can use adjectives and finally be:

sentence : nounPhrase verbPhrase PERIOD

nounPhrase : optArticle optAdjList NOUN

verbPhrase : VERB nounPhrase

optArticle : ARTICLE | *empty*

optAdjList : adjList | *empty*

adjList : ADJECTIVE | ADJECTIVE adjLis

KUDOS the person that can do this correctly and help me with this.

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions