+(reset)-

Formal grammar

In this section you will learn how to define the grammar.

Basic definitions

As you know,the languages ​​are divided into natural and formal.

Formal language is a set of words ,i.e. finite strings of letters,symbols or tokens. In computer science they are used for the precise definition of data formats and the syntax of programming languages.

An alphabet,in the context of formal languages can be any set,although it often makes sense to use an alphabet in the usual sense of the word,or more generally a character set such as ASCII. The elements of an alphabet are called its letters.

Example:

V={0,1,2,3,4,5,6,7,8,9}

V ={a,b,b}

Word is the smallest free form that may be uttered in isolation with semantic or pragmatic content.

The word length is the number of symbols contained in the chain.

Example:

|wolf| = 4
|#@$!&|=5
|chapter|= 7
|ε| = 0

Grammar

A formal grammar (sometimes simply called a grammar) is a set of formation rules for strings in a formal language. The rules describe how to form strings from the language’s alphabet that are valid according to the language’s syntax. A grammar does not describe the meaning of the strings or what can be done with them in whatever context—only their form.

Formal grammar G is written as follows:

G = <N,V,P,S>

where:

N - a finite set of nonterminal symbols
V - a finite set of terminal symbols
P - a finite set of production rules
S - a start symbol (one of the terminal symbol)

Questions

  • Is the alphabet can be a set of natural numbers?
  • What is the length of the word „seven”?
  • Can be the start symbol S the terminal symbol?

If you do not know the answer to these questions,read again the above content.