Grammars are useful models when designing software that processes data with a recursive structure.
To see how a grammar is defined to be able to parse it in a compiler. See Language - (Grammar | Syntax | Lexicon)
Every language displays a structure called its grammar or syntax.
The Grammar is also known as:
- Formal Grammar (formal meaning with structure)
- The Syntax
- The Language structure
- The lexicon (The input file of the lexer)
The syntax of a computer language is the set of rules that defines the combinations of symbols (text or visual) that are considered to be a correctly structured document or fragment in that language.
A syntax does not only define the set of sentences of a language, but also provides them with a structure.
Structure / Building Block / Construct
The following expressions are the basis building block of any language:
- conditionals flow like if statements to make decisions.
- loops to repeat tasks until a condition stops being true.
- operators to perform basic known operation on value.
- comment to document the code.
The definition on how you write of all this building block is called a grammar.
Others constructs common to many languages