Syntax And Semantics

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Syntax And Semantics as PDF for free.

More details

  • Words: 578
  • Pages: 21
Syntax And

Semantic

SYNTAX: A set of strict grammar rules, symbols, and special words used to construct a computer program. There are syntax rules (grammar: how valid instructions are written, what combinations of symbols can be used)

Cont.. Syntax is the grammar of the language, that is the rules for constructing valid statements in that language. If you break the rules the compiler will complain.

Cont…. Study of the rules that govern the structure of sentences, and which determine their relative grammaticality. The term syntax can also be used to refer to these rules themselves, as in “the syntax of a language”.

SYNTAX ERROR: If a syntax error is encountered during compilation( mapping high level language to low level language) it must be corrected if the source code is to be successfully compiled.

Cont.. Syntax errors may also occur when an invalid equation is entered into a calculator. This can be caused by opening brackets without closing them, or less commonly, using several decimal points in one number.

Cont.. GOOD compiler should help in identifying and locating errors. Any token which doesn’t match grammar rule is part of syntax error i.e arithematic expression with unbalance paranthesis.

Recovery: If we have a good idea of common error that might be encountered at hand. End with delimiter Never go in infinite loop Replace comma (,) by semicolon(;)

Semantic: Semantic is MEANING OF STATEMENT COMPATIBILITY OF STATEMENT CORRECT USAGE OF STATEMENT

Cont.. Computers can't read your mind, so they don't help much if the meaning of your program is not what you wanted.

Cont.. In this regard, semantics permits programs to be separated into their syntactical part (grammatical structure) and their semantic part (meaning).

FOR EXAMPLE IF INTEAD OF X = 1; STMT IT WERE GIVEN AS Y = 1; WHERE X was declared in program BUT Y was not

Cont.. Scope of variable is the range of program instruction over which the variable is known. If the program uses undeclare name such as -Y = 1

Cont.. Introduces (ambiguous name) For example int X char X

C++ Syntax and Semantics 3. Mark the following expressions as either legal or illegal, Indicate whether the value is an integer or a floating point value. Valid Invalid integer floating point

10 + 3 -9.4 - 6.2 10.0 / 3.0 10 / 3 4/8

Cont… x * y = c; y = con; const int x : 10; int x: a = b % c;

invalid valid invalid invalid

ALGORITHM Step-by-step procedures for solving a problem in a finite amount of time. Algorithms encompass far more than computer programs. We are learning to write algorithms and the computer is simply a fast and flexible tool for implementing algorithms.

An algorithm is an ordered set of instructions such that: (1) There are a finite number of steps. (2) It takes a finite amount of time to execute the steps. (3) Each step is precise in meaning.

(4) It is deterministic. during the execution of an algorithm, the information must be sufficient to determine uniquely and completely the actions required by each step.

(5) It solves a general class of problems ensures that the algorithm is general enough that it solves a general set of problems, and not one specific/particular problem

INCLUSION: the execution of each step in an algorithm does not require creative skills, it requires rather only the ability to follow directions. In specifying behavior, an algorithm must be precise, unambiguous, complete, and correct.

Related Documents

Syntax And Semantics
November 2019 18
Semantics
September 2019 32
Syntax
May 2020 13
Morphology And Syntax
April 2020 8
Bahan Semantics
April 2020 24
Semantics-new.pptx
May 2020 15