An arithmetic expression language
Arithmetic expressions are part of every programming language. Here is an example of an arithmetic expression calculation language called calc. calc expressions are compiled into an application that evaluates the following expression:
with a, b: a * (4 + b)
The variables that are used in the expression must be declared with the with
keyword. This program is compiled into an application, which asks the user for the values of the a
and b
variables and prints the result.
Examples are always welcome but as a compiler writer, you need a more thorough specification than this for implementation and testing. The vehicle for the syntax of the programming language is its grammar.
Formalism for specifying the syntax of a programming language
The elements of a language, such as its keywords, identifiers, strings, numbers, and operators, are called tokens. In this sense, a program is a sequence of tokens, and the grammar specifies which sequences...