Download presentation
Presentation is loading. Please wait.
1
C++ Parse Analysis Introduction
Kei Hasegawa
2
Ex1:Declaration struct T { T(); /* ... */ }; T::T() { /* ... */ };
T (a); // Declaration of `a’
3
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’.
4
Ex2:Initializer struct T { /* ... */ }; int a;
T t(a); // Declaration of variable `t’ typedef int A; T t2(A); // Declaration of function `t2’
5
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 ‘)’.
6
Ex3: Template template<class C> class T { /* ... */ };
T<char> tc; At the timing of reading `T<char>’, instantiation starts.
7
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]; };
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.