Formal grammar is a set of rules and structures that define the syntax of a language. It provides a formal way to describe how sentences or expressions in a language can be constructed. Formal grammars are widely used in computer science, linguistics, and artificial intelligence to define programming languages, natural languages, and various systems of communication.
Articles by others on the same topic
A formal grammar specifies how to generate a formal language by repeated applications of production rules. Write , where is a finite set of nonterminal symbols, is a disjoint finite alphabet of terminal symbols, is the start symbol, and is a finite set of production rules . In an unrestricted formal grammar, the word must contain at least one nonterminal symbol; may be any word over .
A grammar derivation replaces an occurrence of inside a word by . The generated formal language isIntermediate words may still contain nonterminal symbols; these are sentential forms. For example, the production rules and give and generate exactly . Restricting each left side to one nonterminal symbol gives a context-free grammar.[ref]
Introduction to the Theory of Computation by Jean Gallier (2017). Sections6.1–6.2, printed pp.127–129, context-free grammar and derivation definitions