preview

Syntax And Syntax

Decent Essays

The task of providing a simple description of a programming language is very difficult but it is essential to the language’s success.
ALGOL 60 and 68 was initially represented using compact formal descriptions; in both scenarios, however, the description was not clear because they utilized a completely new notation. Hence, both these languages were not accepted by the developer community. Similarly, few languages have faced some issues due to different dialects, a result of simple but informal and imprecise description.
The study of programming languages is similar to natural languages. It can be classified into Syntax refers to the spelling and grammar of a programming language. The syntax of a programming language is the combination …show more content…

Semantics shows the meaning of syntactically valid strings in a programming language. For programming languages, semantics explains the behavior of computer follows when executing a program in the language.
In this chapter, you will learn about syntax and semantics. You will gain a knowledge of the uses of syntax and semantics. You will learn about types of semantics and approaches of syntax and semantics. You will also know the general problems and formal methods of syntax

Overview of Syntax and Semantics
A programming language includes a set of rules, symbols, and special words which is used to construct a program. Rules are applied to both syntax (grammar) and semantic (meaning). Syntax refers to grammatical structure whereas the term semantics refers to the meaning of the vocabulary symbols arranged with that structure. A programming language syntax is formalized by a grammar or syntax.
Let us consider of an example of syntax and semantics using while statement in C language while (expression)
{
Statement or code to be executed …show more content…

• Syntax rules of a programming language defines the spelling and grammar. In syntax, each and every language has its own rules.
• Computers are very inflexible and understand what you write only if you state what you want in exact syntax that the computer expects and understands.
Importance of semantics
• Semantics is referred to the meaning of words and sentences.
• Mostly semantics studies the understanding of each word and creates the sentences in the form of text written.
• Semantics offers a framework for easy understanding and analyses the fundamental requirement of languages.
Syntax
Syntax refers in different way of symbols that combined to create well-formed sentences in the language. It defines the formal relations between the components of a programming language. So, it provides a structural description of the various expressions which makes strings in the language.
Syntax Composition

Tokens: A token consists of a token name and an optional attribute value. Different types of Tokens are namely, keywords, identifiers, constants, and operator symbols. The syntax of token is token_name, value

Get Access