In formal languages, we encounter the term symbol which is the basic element
of a dictionary. Dictionary is the basis of every language. It is the feature
of every language that certain sequences of words are recognised as correct,
and others as incorrect. A correct sequence of words is called
a sentence. The decision on the
correctness of a sentence is made based on grammar, that is the structure
of language (syntax). Syntax is composed of rules and laws that define
a set of formally correct sentences. A set of rules that allows to determine
whether a certain set of words is called syntax or semantics. It is noteworthy
that syntax and semantics are closely related to each other. Formal language
is a subset of a set of finite strings consisting of elements of a finite
set called the alphabet.
Example1:
<sentence> ::= <objective> <predicate>
<objective>::= flowers | stars
<predicate>::= bloom | shine
Sentences that can be constructed from this formal grammar: flowers bloom,
stars shine, stars bloom, flowers shine.
In the formal language defined by the grammar from example 1, the
sentence consists of a subject and a predicate that follows it. Subject
is the words stars or the word flowers, whereas predicate is the word bloom
or the word shine. Syntax determines the correct structures of sentences,
however, it does not deal with their meaning, that is their semantics.
The last two sentences are grammatically correct, however, their semantics
is incorrect.