# Formal grammar

In computer science a language is defined by *formal gramar*. In formal language theory, a grammar is a set of *production rules* for strings that form a language. The rules describe how to form strings from the *language alphabet* that are valid according to the *language syntax*.

See also: wikipedia formal grammar

## Grammar description

We use several specific notations to describe grammar.

- We enclose identifier names in angle brackets <>;
- Identifiers are starting with a letter and contain letter or numbers;
- We enclose optional elements in squared brackets [];
- We represent alternative (or) using the vertical bar “|”;
- A repeating sequence of elements is represented using 3 dots: “…”

## Mathematical Expressions

Is a finite combination of symbols that is *well-formed* according to rules that depend on the context. Mathematical symbols can designate numbers elements, operators or tokens: {constants, variables, operations, functions, punctuation, grouping}, and some other aspects of *logical syntax*.

### Well-formed (syntax)

A well-formed expression is a syntactic concept. A syntax is a set of rules, principles, and processes that govern the structure of a given language.

In a correct expression the operators must have the correct number of inputs in the correct places, the characters that make up these inputs must be valid. Enumeration of symbols that violate syntax rules are not well-formed and are not valid mathematical expressions.

For example, in the usual notation of arithmetic, the expression 2 + 3 is well-formed, but the following expression is not: \times4)x+,/y.

### Expression form (semantic)

Mathematical expressions include multiple forms of expressions: {arithmetic, polynomial, algebraic, closed-form, and analytical}. The form of an expression is a semantics concept.Semantics is the study of meaning. Formal semantics is about attaching meaning to expressions.

### Expression evaluation

An expression may be used to designate a value, which might depend on variables occurring in the expression. The determination of this value depends on the semantics attached to the symbols of the expression.

Certain expressions do not designate any value, for instance when they involve division by 0; such expressions are said to have an undefined value, but they are well-formed expressions nonetheless.

### Logical expressions

In general the meaning of expressions is not limited to designating values; for instance, an expression might designate a condition, or an equation that is to be solved, or it can be viewed as an object in its own right that can be manipulated according to certain rules.

# How compiler works?

** **In order to build a compiler for Level I have started my research several weeks ago. Until now I have understood some basic concepts and I have started to implement the compiler components. Next I wil present the compiler components created for project Level-PY. That is a python compiler for Level-3.