[go: up one dir, main page]

0% found this document useful (0 votes)
21 views10 pages

Lec 2 Syntax

Uploaded by

Lhovie Gayo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views10 pages

Lec 2 Syntax

Uploaded by

Lhovie Gayo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

SYNTAX

IT2-Lecture 2
Syntax

• Form in which programs are written


• Correct symbols and correct use of
the symbols
Basic ingredients of the syntax of the
language
• Character Set
• Also called the alphabet
• Set of symbols use in PL
• It’s a practice for a PL to use standard such as the
ASCII set

• Example:
• Machine Language – 0 and 1 (2 characters)
• Algol-60 – 52 small and capital letters, 10 digit and 52
special character ( a total of 114 characters.
Basic ingredients of the syntax of the
language
• Identifiers
• Use to name the data object, procedure, and keywords
• Must consider rules such as length, valid characters,
and case sensitivity

• Example:
• In C identifiers must not exceed to 32 characters
• In Java identifiers are case sensitive
• In BASIC identifiers can be a capital followed by
Basic ingredients of the syntax of the
language
• Operator Symbols
• Used to represent primitive operations in the PL
• Example:
• +, -, *, /, %, =, ==, etc. in Java
• .EQ. for FORTRAN
• ADD to add in COBOL
Basic ingredients of the syntax of the
language
• Keywords and Reserved Words
• Keywords are special words that are used as part of the syntax

• Example:
• begin and end in PASCAL
• do and if in C

• Reserved words are special words that has a special


meaning in the PL

• Example:
• void in C
• true and false in Java
Basic ingredients of the syntax of the
language
• Comments and Noise Words
• Comments are words that are ignored during
compilation or interpretation

• Example:
• { and } in Pascal
• // in C++
• /* */ in C
• /** */ in Java
Basic ingredients of the syntax of the
language
• Delimiter and Bracket
• A delimiter is a syntactic elements that is used to mark
the start and end of some constructs
• Example:
• ; in C++ and Java
• : in BASIC

• A Bracket are used to enclose a group of statement

• Example:
• { and } in C++
Basic ingredients of the syntax of the
language
• Expression
• Basic syntactic elements that are used in most
statement
• Used to indicate condition and to evaluate values
assigned to variables

• Example:
• 4 == 4 (which result to true)
• a=b+c;
• if(a>b) a=a-b; else a=a+b;
Basic ingredients of the syntax of the
language
• Statement
• smallest components of the program that contains
executable code
• usually contains expression
• may be simple or compound

• Example:
• cout<<“Hello, C++ Program”;

You might also like