Context Free Grammar (CFG) - 2021
Context Free Grammar (CFG) - 2021
Context Free Grammar (CFG) - 2021
A context-free grammar consisting of a finite set of grammar rules is a quadruple (N, T, P, S). CFG is
a set of recursive rules used to generate patterns of strings. A CFG can describe all regular
languages and more, but they cannot describe all possible languages.
Problem:
Write a CFG for the language whose specifications are given bellow:
• Consider the name of the language is ASL (A Sample Language).
• An ASL programme starts with the word Begin and finishes with the word End.
• The programme consists of declaration and statements.
• The declaration starts with variable_list followed by a colon and a type.
• Type should be integer or real or character or string.
• Statements should be assaignemt stmt, print stmt, input stmt, and if stmt.