SYNTAX TRB CSI › Programming with C++ › syntax

SYNTAX

Syntax என்பது ஒரு programming language-ல் program statements எப்படி எழுதப்பட வேண்டும் என்பதை define செய்யும் formal grammatical rules. Simple Tamil: Programming language-ன் grammar தான் Syntax. English-ல் sentence எழுத grammar rules இருப்ப…

Premium — locked Intermediate 32 min 294 cards 52 programs 10 MCQs v3
This is a premium lesson. You can see the shape of every card — unlock to read them. Unlock
Definition

Syntax என்பது ஒரு programming language-ல் program statements எப்படி எழுதப்பட வேண்டும் என்பதை define செய்யும் ……

Premium This card is part of the premium lesson. Unlock
Definition

1. SYNTAX என்றால் என்ன?…

Premium This card is part of the premium lesson. Unlock
Definition

Programming language-ல்: Keywords Identifiers Operators Symbols Expres……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

இதில் syntax rules: if keywor……

Premium This card is part of the premium lesson. Unlock

SIMPLE REAL-LIFE COMPARISON

Explanation

English: Raja eats an apple. Grammar correct. Raja apple an eats. Words இருக்கின்றன. ஆனால் grammatical arrang……

Premium This card is part of the premium lesson. Unlock

SYNTAX vs SEMANTICS

Explanation

மிகவும் important distinction. Code……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

Syntax correct. Semantics: Current x ……

Premium This card is part of the premium lesson. Unlock

LEXICAL STRUCTURE AND SYNTAX

Comparison

Programming language syntax-ஐ புரிந்து கொள்ள இரண்டு levels important: Lexical Structure ↓ Syntax Structure Le……

Premium This card is part of the premium lesson. Unlock

TOKEN

Definition

Programming language-ன் small……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

int total = 100; Tokens: int total = 100 ; Classific……

Premium This card is part of the premium lesson. Unlock

TYPES OF TOKENS

Explanation

C++-ல் commonly: Tokens | +-- Keywords +-- ……

Premium This card is part of the premium lesson. Unlock

KEYWORDS

Explanation

Language predefined reserved words. Examples: int if else for while return clas……

Premium This card is part of the premium lesson. Unlock

IDENTIFIERS

Explanation

Variables, functions, classes ……

Premium This card is part of the premium lesson. Unlock
Explanation

Function: int add()…

Premium This card is part of the premium lesson. Unlock
Explanation

Class: class Student…

Premium This card is part of the premium lesson. Unlock

IDENTIFIER SYNTAX RULES

Explanation

C++ identifier பொதுவாக: Letter அல்லது underscore மூலம் start ஆகலாம். Digits later வரலாம். Spaces இர……

Premium This card is part of the premium lesson. Unlock

LITERALS

Explanation

Program-ல் directly written fixed values. Examples: 10 Integer lit……

Premium This card is part of the premium lesson. Unlock

OPERATORS

Explanation

Operations represent செய்யும்……

Premium This card is part of the premium lesson. Unlock
Explanation

&& ||…

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

Here: = → assignment operator…

Premium This card is part of the premium lesson. Unlock
List

- → arithmetic operator…

Premium This card is part of the premium lesson. Unlock

PUNCTUATORS

Explanation

Programming syntax structure define செய்ய உதவும் symbols. Examples: ; ……

Premium This card is part of the premium lesson. Unlock
Explanation

{} block.…

Premium This card is part of the premium lesson. Unlock

EXPRESSION SYNTAX

Definition

Operands மற்றும் operators-ன்……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

a + b Valid expression. Anoth……

Premium This card is part of the premium lesson. Unlock

OPERAND

Explanation

Operator operation செய்யும் v……

Premium This card is part of the premium lesson. Unlock
List

- → Operator…

Premium This card is part of the premium lesson. Unlock
Explanation

b → Operand…

Premium This card is part of the premium lesson. Unlock

STATEMENT SYNTAX

Definition

Programming language-ல் ஒரு c……

Premium This card is part of the premium lesson. Unlock
Program
Example
Program
Expression
Program
Complete C++ statement

DECLARATION SYNTAX

Explanation

C++ variable declaration: data_type variable_nam……

Premium This card is part of the premium lesson. Unlock

ASSIGNMENT SYNTAX

Syntax
General form
Program
Example
Program
Another

IF STATEMENT SYNTAX

Program
General
Program
Example
Program
Important syntax elements

IF-ELSE SYNTAX

Program
Example

FOR LOOP SYNTAX

Program
Example
Program
Structure

WHILE LOOP SYNTAX

Explanation
Example

int i = 1;…

Premium This card is part of the premium lesson. Unlock

FUNCTION SYNTAX

Explanation

General: return_type function_name(parameters) { statements; return value; } int add(int a,……

Premium This card is part of the premium lesson. Unlock

CLASS SYNTAX

Program
C++
Program
Example
Important

Class definition முடிவில்: }; semic……

Premium This card is part of the premium lesson. Unlock

SYNTAX ERROR

Definition

Programming language grammatical r……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

Missing: ; Compiler syntax er……

Premium This card is part of the premium lesson. Unlock

COMMON C++ SYNTAX ERRORS

Explanation

Missing semicolon Missing braces Missing parentheses In……

Premium This card is part of the premium lesson. Unlock

MISSING SEMICOLON

Explanation

Wrong: int x = 10 Correct: in……

Premium This card is part of the premium lesson. Unlock

MISSING PARENTHESIS

Program
Wrong
Program
Correct C++

MISSING BRACE

Program
Wrong
Explanation

Closing: } missing.…

Premium This card is part of the premium lesson. Unlock

UNCLOSED STRING

Program
Wrong
Program
Correct

CASE SENSITIVITY

Explanation

C++ case-sensitive language. int total = 10; and: in……

Premium This card is part of the premium lesson. Unlock

FORMAL SYNTAX

Explanation

Programming language syntax natural-language explanation மட்டும் அல்ல. Mathematical / formal……

Premium This card is part of the premium lesson. Unlock

GRAMMAR

Definition

Programming language-ல் valid sentences/program structures உருவாக்கும் fo……

Premium This card is part of the premium lesson. Unlock

TERMINAL SYMBOL

Definition

Grammar-ல் further replace செய்ய முடியாத actual……

Premium This card is part of the premium lesson. Unlock

NON-TERMINAL SYMBOL

Definition

Grammar structure represent செய்யும் variable-like ……

Premium This card is part of the premium lesson. Unlock

PRODUCTION RULE

Definition

ஒரு non-terminal எப்படி expan……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

::= +…

Premium This card is part of the premium lesson. Unlock
Definition
Meaning

ஒரு expression மற்றொரு expres……

Premium This card is part of the premium lesson. Unlock

BNF

Definition

BNF = Backus-Naur Form Programming la……

Premium This card is part of the premium lesson. Unlock
Explanation
General form

::= definition ::= 0 | 1 | 2 | 3 | 4 | ……

Premium This card is part of the premium lesson. Unlock

BNF SIMPLE EXAMPLE

Explanation

Suppose identifier: ::= | |…

Premium This card is part of the premium lesson. Unlock
Definition
Meaning

Identifier: letter மட்டும் இருக்கலாம் o……

Premium This card is part of the premium lesson. Unlock

EXPRESSION GRAMMAR

Explanation
Example

::= + | ::= * | ::= identifier | number This gr……

Premium This card is part of the premium lesson. Unlock

DERIVATION

Explanation

Grammar production rules பயன்படுத்தி start symbol-இலிருந்து v……

Premium This card is part of the premium lesson. Unlock

LEFTMOST DERIVATION

Explanation

ஒவ்வொரு step-லும் leftmost non-terminal முத……

Premium This card is part of the premium lesson. Unlock

RIGHTMOST DERIVATION

Explanation

Rightmost non-terminal முதலில் replace செய்த……

Premium This card is part of the premium lesson. Unlock

PARSE TREE

Definition

Grammar மூலம் program/string எப்படி derive செய……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

a + b Parse tree: Expr / | \ ……

Premium This card is part of the premium lesson. Unlock

COMPLEX EXPRESSION PARSE TREE

Explanation

Expression: a + b * c Correct……

Premium This card is part of the premium lesson. Unlock
Definition
Meaning

a + (b * c) Multiplication fi……

Premium This card is part of the premium lesson. Unlock

PARSING

Definition

Input tokens grammar rules follow செய்கிறதா என்று analyze செய்யும் ……

Premium This card is part of the premium lesson. Unlock

LEXICAL ANALYZER

Definition

Source program characters-ஐ t……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

int x = 10; Lexical analyzer output conce……

Premium This card is part of the premium lesson. Unlock

PARSER

Explanation

Tokens valid grammar structure-ல் இருக்கிறதா என்று ch……

Premium This card is part of the premium lesson. Unlock

LEXICAL ANALYSIS vs SYNTAX ANALYSIS

SCANNER

Explanation

Lexical analyzer-க்கு another……

Premium This card is part of the premium lesson. Unlock
Explanation

Exam MCQ-க்கு important.…

Premium This card is part of the premium lesson. Unlock

PARSER ERROR

Program
Suppose tokens valid individually
Explanation

int, =, x, 10, ; எல்லாம் recognizable tokens. ஆனால் grammar order w……

Premium This card is part of the premium lesson. Unlock

CONTEXT-FREE GRAMMAR

Explanation

Programming language syntax பெரும்பாலும்: Contex……

Premium This card is part of the premium lesson. Unlock

CFG COMPONENTS

Explanation

Context-Free Grammar mathemat……

Premium This card is part of the premium lesson. Unlock
Explanation

TRB / NET / SETக்கு இது முக்க……

Premium This card is part of the premium lesson. Unlock

START SYMBOL

Explanation

Grammar derivation தொடங்கும் speci……

Premium This card is part of the premium lesson. Unlock

META-LANGUAGE

Explanation

Programming language syntax describe செய்ய பயன்படுத்தப்படும் language/notati……

Premium This card is part of the premium lesson. Unlock

EBNF

Definition

EBNF = Extended Backus-Naur Form BNF-ன் extended versi……

Premium This card is part of the premium lesson. Unlock

EBNF COMMON SYMBOL IDEAS

Definition

Notation standard-ஐ பொறுத்து symbols vary செய்யலாம், ……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

= { | }…

Premium This card is part of the premium lesson. Unlock
Definition
Meaning

First letter + zero or more l……

Premium This card is part of the premium lesson. Unlock

ABSTRACT SYNTAX

Definition

Programming language syntax இரண்டு levels-ல் பார்க்கப்படு……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

a + b; Includes: parentheses ……

Premium This card is part of the premium lesson. Unlock

ABSTRACT SYNTAX

Explanation

Program-ன் essential structural meaning மட்டும் repre……

Premium This card is part of the premium lesson. Unlock

AST

Explanation

Expression: a + b * c AST: + / \ a * ……

Premium This card is part of the premium lesson. Unlock

PARSE TREE vs AST

AMBIGUOUS GRAMMAR

Definition

ஒரே input string-க்கு ஒன்றுக்கு மேற்பட்ட parse trees கிடைத்தால் grammar: Ambiguous Grammar என்று அழைக்கப்படும……

Premium This card is part of the premium lesson. Unlock
Definition

1. WHY AMBIGUITY IS A PROBLEM?…

Premium This card is part of the premium lesson. Unlock
Definition

Compiler-க்கு: Which interpretation is correct? என்று ambiguity வரும். Programming langua……

Premium This card is part of the premium lesson. Unlock

OPERATOR PRECEDENCE

Definition

எந்த operator first evaluate ……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

2 + 3 * 4…

Premium This card is part of the premium lesson. Unlock
List

- precedence greater than +.…

Premium This card is part of the premium lesson. Unlock
Explanation

Therefore: 3 * 4 = 12 2 + 12 ……

Premium This card is part of the premium lesson. Unlock

ASSOCIATIVITY

Explanation

Same precedence operators multiple இருந்தால் evaluation/grouping ……

Premium This card is part of the premium lesson. Unlock

LEFT ASSOCIATIVE

Explanation

Grouping: a - b - c as: (a - ……

Premium This card is part of the premium lesson. Unlock

RIGHT ASSOCIATIVE

Explanation

Assignment operators commonly……

Premium This card is part of the premium lesson. Unlock
Concept

a = (b = (c = 10))…

Premium This card is part of the premium lesson. Unlock

PRECEDENCE vs ASSOCIATIVITY

SYNTAX DIAGRAM / RAILROAD DIAGRAM

Concept

Grammar rules graphically represe……

Premium This card is part of the premium lesson. Unlock
Concept

Start → if → (condition) → statement → End P……

Premium This card is part of the premium lesson. Unlock

STATIC SYNTAX

Concept

சில language rules pure context-free grammar மட்டும் கொண்டு முழுமையாக express செய்ய முடியாது. Examples: Varia……

Premium This card is part of the premium lesson. Unlock

SYNTAX AND COMPILER

Concept

Compiler flow: Source Program ↓ Lexical Analysis ↓ Tokens ↓ Syntax Analysis ↓ Par……

Premium This card is part of the premium lesson. Unlock

SYNTAX ANALYZER

Concept

Another name: Parser Therefor……

Premium This card is part of the premium lesson. Unlock

COMPILER ERROR STAGES

Explanation
Example

int x = ; Syntax error.…

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

y declared இல்லையெனில் name/semantic analysis error. int x ……

Premium This card is part of the premium lesson. Unlock

C++ BASIC SYNTAX

Program
Minimal C++ program
Program
Breakdown
Explanation

using namespace std; → Namesp……

Premium This card is part of the premium lesson. Unlock
Explanation

{ } → Block…

Premium This card is part of the premium lesson. Unlock
Explanation

return 0; → Return statement…

Premium This card is part of the premium lesson. Unlock

BLOCK STRUCTURE

Explanation

Statements { } braces-க்குள் ……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

Both statements belong to sam……

Premium This card is part of the premium lesson. Unlock

SEMICOLON RULE

Explanation

C++-ல் many statements: ; மூல……

Premium This card is part of the premium lesson. Unlock
Explanation

But control block header afte……

Premium This card is part of the premium lesson. Unlock
Explanation

இதன் closing brace பிறகு normal……

Premium This card is part of the premium lesson. Unlock
Explanation

semicolon required.…

Premium This card is part of the premium lesson. Unlock

WHITESPACE

Explanation

Spaces, tabs, newlines many contexts-ல் tokens separate செய்ய உதவும். ……

Premium This card is part of the premium lesson. Unlock

COMMENTS AND SYNTAX

Explanation

C++ comments: Single line: // comment Multi-line: /* comment */ Comments……

Premium This card is part of the premium lesson. Unlock

FREE-FORM LANGUAGE

Explanation

C++ largely free-form languag……

Premium This card is part of the premium lesson. Unlock
Definition
Meaning

Statements fixed columns-ல் எ……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

syntactically possible. Reada……

Premium This card is part of the premium lesson. Unlock
Explanation

preferred.…

Premium This card is part of the premium lesson. Unlock

SYNTAX DESIGN GOALS

Explanation

Programming language syntax நல்லதாக இருக்க வேண்டுமெனில்……

Premium This card is part of the premium lesson. Unlock

READABILITY

Program
Good syntax
Explanation

condition clear. Complex/unusu……

Premium This card is part of the premium lesson. Unlock

WRITABILITY

Explanation

Syntax programmer-க்கு code easy-ஆக ……

Premium This card is part of the premium lesson. Unlock
Explanation

Both valid; concise forms wri……

Premium This card is part of the premium lesson. Unlock

SYNTACTIC SUGAR

Definition

Language-ல் already possible operation-ஐ easier/convenient syntax மூல……

Premium This card is part of the premium lesson. Unlock
Important

Syntactic sugar generally new fundamental compu……

Premium This card is part of the premium lesson. Unlock

CONCRETE EXAMPLE OF SYNTAX CHECKING

Compiler front-end: Step 1 Characters: i n t t o t a l ... Step 2 Tokens: int total = a + 10 ; Step 3 Parser ……

Premium This card is part of the premium lesson. Unlock
Flow

Characters ↓ Lexical Analyzer ↓ Tokens ↓……

Premium This card is part of the premium lesson. Unlock
Explanation
Syntax

= Rules defining the structure/form of valid programs. Grammar = Formal set of rules describing synt……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Common error

Confuse செய்ய வேண்டாம்: Syntax ≠ Semantics Token ≠ Character Lexical Analyzer ……

Premium This card is part of the premium lesson. Unlock
Memory Trick

S → Syntax → Structure G → Grammar → Rules T → Token → Tiny meaningful unit P → Par……

Premium This card is part of the premium lesson. Unlock
TRB Point

1. The grammatical structure ……

Premium This card is part of the premium lesson. Unlock
TRB Point

Answer: Syntax…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Programming language synta……

Premium This card is part of the premium lesson. Unlock
TRB Point

Answer: Grammar…

Premium This card is part of the premium lesson. Unlock

BNF stands for:

TRB Point

Answer: Backus-Naur Form…

Premium This card is part of the premium lesson. Unlock

Smallest meaningful lexical unit:

TRB Point

Answer: Token…

Premium This card is part of the premium lesson. Unlock

Syntax analyzer is also called:

TRB Point

Answer: Parser…

Premium This card is part of the premium lesson. Unlock

Lexical analyzer is also called:

TRB Point

Answer: Scanner…

Premium This card is part of the premium lesson. Unlock

A tree representing grammatical structure:

TRB Point

Answer: Parse Tree…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. If one sentence has more t……

Premium This card is part of the premium lesson. Unlock
TRB Point

Answer: Ambiguous…

Premium This card is part of the premium lesson. Unlock

CFG is represented by:

TRB Point

Answer: G = (V, T, P, S)…

Premium This card is part of the premium lesson. Unlock

Operator priority is called:

TRB Point

Answer: Precedence…

Premium This card is part of the premium lesson. Unlock
MCQ

Syntax specifies:…

Premium This card is part of the premium lesson. Unlock
MCQ

Which formalism is widely use……

Premium This card is part of the premium lesson. Unlock
MCQ

BNF stands for:…

Premium This card is part of the premium lesson. Unlock
MCQ

Which compiler phase converts……

Premium This card is part of the premium lesson. Unlock
MCQ

Which compiler component chec……

Premium This card is part of the premium lesson. Unlock
MCQ

A grammar with more than one ……

Premium This card is part of the premium lesson. Unlock
MCQ

Which is a non-terminal?…

Premium This card is part of the premium lesson. Unlock
MCQ

::= in BNF means:…

Premium This card is part of the premium lesson. Unlock
MCQ

Which determines whether * or……

Premium This card is part of the premium lesson. Unlock
MCQ

Which of the following is the……

Premium This card is part of the premium lesson. Unlock
TRB Point
Exam point

2 Marks - Define Syntax Syntax is the set of formal grammatical rules that specifies the structure and form o……

Premium This card is part of the premium lesson. Unlock
Summary

Programming Language ↓ Characters ↓ Lexical Analysis ↓ Tokens ……

Premium This card is part of the premium lesson. Unlock
Explanation
Syntax

| +-- Tokens +-- Grammar +-- Terminals +-- Non-terminals +-- Productions +-- BNF +-- EBNF +-- Derivation +-- ……

Premium This card is part of the premium lesson. Unlock
Text size
17px
Theme
Contents
Print / PDF
Program