1 Lexical Elements Chapter 2 in ABC. 2 Tokens Token = word / symbol, does not contain white spaces. Tokens in C are either: –keywords –identifiers –constants.

Slides:



Advertisements
Similar presentations
Pemrograman C Risanuri Hidayat. Why C  Compact, fast, and powerful  “Mid-level” Language  Standard for program development (wide acceptance)  It is.
Advertisements

10 November JavaScript. Presentation Hints What do YOU think makes a good presentation Some of my suggestions Don’t write full sentences on slides Talk,
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction.
Mini-Pascal Compiling Mini-Pascal (MPC) language
JavaScript, Third Edition
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
1 Lecture 3  Lexical elements  Some operators:  /, %, =, +=, ++, --  precedence and associativity  #define  Readings: Chapter 2 Section 1 to 10.
1 Structured Programming in C Welcome to CPSC 206.
Data Types.
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
C Programming Lecture 4. Tokens & Syntax b The compiler collects the characters of a program into tokens. Tokens make up the basic vocabulary of a computer.
Variable & Constants. A variable is a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines.
Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Syntax of C Programming Language #Lesson 2 Sen Zhang.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
System development with Java Lecture 2. Rina Errors A program can have three types of errors: Syntax and semantic errors – called.
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
COE 405 VHDL Lexical Elements Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum & Minerals Dr. Aiman H. El-Maleh.
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Characters and tokens Characters are the basic building blocks in C program, equivalent to ‘letters’ in English language Includes every printable character.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Recognizing PL/SQL Lexical Units. 2 home back first prev next last What Will I Learn? List and define the different types of lexical units available in.
Chapter 2 Variables.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Topics to be covered  Introduction to C Introduction to C  Characterstics of C Characterstics of C  Characterset Characterset  Keywords Keywords 
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
Tokens in C  Keywords  These are reserved words of the C language. For example int, float, if, else, for, while etc.  Identifiers  An Identifier is.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
1 Lexical Elements, Operators, and the C System. 2 Outline Characters and Lexical Elements Syntax Rules Comments Keywords Identifiers Constants String.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Introduction to C Programming
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
Compiler Chapter 4. Lexical Analysis Dept. of Computer Engineering, Hansung University, Sung-Dong Kim.
C Formatted Input/Output
C++ First Steps.
Chapter 2 Variables.
Tokens in C Keywords Identifiers Constants
Wel come.
Types and Values.
Java Programming: From Problem Analysis to Program Design, 4e
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
C++ Basics.
Introduction to Java Programming
Basics of ‘C’.
Lectures on Numerical Methods
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Comments Any string of symbols placed between the delimiters /* and */. Can span multiple lines Can’t be nested! Be careful. /* /* /* Hi */ is an example.
Unit 3: Variables in Java
Chapter 2 Variables.
Lexical Elements & Operators
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Basic Java structural components
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

1 Lexical Elements Chapter 2 in ABC

2 Tokens Token = word / symbol, does not contain white spaces. Tokens in C are either: –keywords –identifiers –constants –operators + - || =... –punctuation:, ;{ }

3 Comments Arbitrary strings placed between the delimiters /* and */. /* * A comment can be written in this fashion * to set it off from the surrounding code. */ The (pre-)compiler replaces each comment with a single blank character. int i1/*comment*/,i2 /*comment*/; int i/*comment*/3; In this course we do not use the c++ style!!! // This is not ANSI C!!! int i1,i2 ; int i 3; (gcc -E)

4 Keywords keyword = A reserved word with strict meaning. C does a lot with relatively few keywords. Some implementations on some systems may have additional keywords. autodogotosignedunsignedbreak doubleifsizeofvoidcaseelse intstaticvolatilecharenumlong structwhileconstexternregisterswitch continuefloatreturntypedefdefaultfor shortunion

5 Identifiers A token composed of a sequence of letters tax = price * tax_rate Alphanumeric characters + '_'. tax-rate tax - rate First character cannot be a digit!! 5a_cse is not legal Case sensitive CSE_5a is different from cse_5a Some identifiers are already taken: keywords. Choose names that are meaningful!! (cse_5a is not a good example...) expression

6 Numeric Constants u L x e2 'a' 'A' ' ' '\t' '\n' '\a' '\0' Suffixes: u or U : unsigned (integers only) l or L : long (ul - unsigned long) too long? cconstant integer (octal base) a constant expression floating constant integer constants  97  65  32 cconstant integer (hexadecimal base)

7 String Constants "a string of text" "" "a = b + c" "a string with double quotes \" within" "a string backslash \\ is in this string" 2 string constants separated by white spaces are concatenated "abc" "def" is equivalent to "abcdef" The NULL string (empty string) Nothing is executed