C++ Parse Analysis Introduction

Slides:



Advertisements
Similar presentations
Incomplete Structs struct B; struct A { struct B * partner; // other declarations… }; struct B { struct A * partner; // other declarations… };
Advertisements

CPSC 388 – Compiler Design and Construction
1 Programming Structures COMP102 Prog. Fundamentals, Structures / Slide 2 2 Structures l A Structure is a collection of related data items, possibly.
Structure.
Chapter 17 Templates. Generic Algorithms Algorithms in which the actions or steps are defined, but the data types of the items being manipulated are not.
Structures Spring 2013Programming and Data Structure1.
C++ Classes & Data Abstraction
Union, bitfield, typedef, enum union nama_u{ }; union nama_u{ struct nama_s byte; }; enum{ }; Tipedef var BYTE.
Lecture 18: 4/11/2003CS148 Spring CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Structures. An array allows us to store a collection of variables However, the variables must be of the same type to be stored in an array E.g. if we.
Lesson 12 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 9: Pass-by-Value.
1 Type Type system for a programming language = –set of types AND – rules that specify how a typed program is allowed to behave Why? –to generate better.
Scope Accessibility of Names. Review We’ve seen that C++ permits a programmer to declare names and then use those names in a manner consistent with their.
Functions, Pointers, Structures Keerthi Nelaturu.
ECE122 Feb. 22, Any question on Vehicle sample code?
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Passing Structure to function.  structure to function structure to function  Passing structure to function in C Passing structure to function in C 
1 Using Yacc. 2 Introduction Grammar –CFG –Recursive Rules Shift/Reduce Parsing –See Figure 3-2. –LALR(1) –What Yacc Cannot Parse It cannot deal with.
Overview of C++ Templates
Reusing Code in C++ Has-a relationship Classes with member objects(containment) The valarray template class Private & protected inheritance Multiple inheritance.
Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.
ENEE150 – 0102 ANDREW GOFFIN Project 4 & Function Pointers.
CS212: Object Oriented Analysis and Design Lecture 22: Generic Class Design.
Introduction to Computers and Programming Class 24 Structures (structs) Professor Avi Rosenfeld.
Lesson 4 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
Structure A collection of values (members) struct date{ int day; char month[10]; int year; }; Declare a structure variable struct date today; struct struct_name.
CGS 3460 Thus Far n Whenever we declare a variable, we specified its data type. n The data type helped us identify the type of information that a variable.
ENEE150 – 0102 ANDREW GOFFIN Abstract Data Types.
Chapter 11 Structures, Unions and Typedef 11.1 Structures Structures allow us to group related data items of different types under a common name. The individual.
 2006 Pearson Education, Inc. All rights reserved Templates.
Computer Programming II Lecture 4. Functions - In C++ we use modules to divide the program into smaller and manageable code. These modules are called.
Java Programming Language Lecture27- An Introduction.
Generic Programming in C
Ex-1 #include <stdio.h> struct sample { int a=0; char b='A';
C++ Templates.
Semantic Analysis with Emphasis on Name Analysis
Structs versus Classes
Structures.
Templates.
Using local variable without initialization is an error.
Object-Oriented Programming (OOP) Lecture No. 32
Introduction to Classes and Objects
Pass by Reference, const, readonly, struct
Array of Structures A structure holds only one record But a record
Programming -2 برمجة -2 المحاضرة-7 Lecture-7.
Arrays and Arrays as Parameters
Introduction to Programming
Object-Oriented Programming (OOP) Lecture No. 37
Template Functions Lecture 9 Fri, Feb 9, 2007.
Object-Oriented Programming (OOP) Lecture No. 38
Overview of C++ Polymorphism
Programming Language C Language.
Compiler Construction
CS150 Introduction to Computer Science 1
Type compatibility and pointer operation
Lab4 problems More about templates Some STL
Templates Generic Programming.
Function Templates Class Templates
CSCE 206 Lab Structured Programming in C
Chapter 10 C Structures and Unions
COP 3330 Object-oriented Programming in C++
nested-name-specifier
C++ parse analysis Save and restore parser state
Compiler Construction
Templates Generic Programming.
Structures, Unions, and Enumerations
Default argument Kei Hasegawa.
Presentation transcript:

C++ Parse Analysis Introduction 2019.02.11 Kei Hasegawa

Ex1:Declaration struct T { T(); /* ... */ }; T::T() { /* ... */ }; T (a); // Declaration of `a’

Ex1:Declaration (continue) T:: T () { /* ... */ } T (a); type-name type-name declarator-id simple-type-specifier Even though parser can recognize ‘(‘ after `T’ , it’s not obvious that which rule should be chosen for `type-name’.

Ex2:Initializer struct T { /* ... */ }; int a; T t(a); // Declaration of variable `t’ typedef int A; T t2(A); // Declaration of function `t2’

Ex2:Initializer (continue) T t ( a ) T t2 ( A ) initializer parameter-declaration-clause declarator-id declarator-id Even though parser can recognize ‘(‘ after `t’ or `t2’, it’s not obvious that it is the start of `initializer’ or ‘(‘ parameter-declaration-clause ‘)’.

Ex3: Template template<class C> class T { /* ... */ }; T<char> tc; At the timing of reading `T<char>’, instantiation starts.

Ex4: member function struct T { }; void f(A a); // Error: `A’ is undeclared. void g() { A a = sizeof(T) + c[5]; /* ... */ } // OK! // ... typedef int A; char c[10]; };