Midterm Winter 2002 - PowerPoint PPT Presentation

About This Presentation
Title:

Midterm Winter 2002

Description:

pointcuts : UNKNOWN-PARSE1 { first : Nonempty_PointCut_List ( it : UNKNOWN-PARSE2 ... pointcuts : UNKNOWN-PARSE1 { first : Nonempty_PointCut_List ( it ... – PowerPoint PPT presentation

Number of Views:9
Avg rating:3.0/5.0
Slides: 51
Provided by: karllie
Category:
Tags: midterm | parse1 | winter

less

Transcript and Presenter's Notes

Title: Midterm Winter 2002


1
Midterm Winter 2002
  • Karl Lieberherr

2
COM 1205
  • has just been renamed from
  • Software Design and Development to
  • Advanced Pattern Matching and Brain Conditioning
  • motivation
  • software development will change, but
  • your pattern matching skills in your brain will
    be useful for the rest of your lives

3
Pattern matching
  • Our brains are good at matching patterns
  • recognize commonalities and differences
  • sometimes have three-way and multi-way pattern
    matching

4
Three-way pattern matching
  • Given two instances of a pattern, find the
    correspondences between the instances and the
    pattern
  • pattern class dictionary
  • instance 1 sentence
  • instance 2 object

5
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
6
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
7
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
8
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
9
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
10
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
11
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
12
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
13
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
14
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
15
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
establish correspondence based on
context knowledge
16
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
establish correspondence using colors
17
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
18
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
19
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
20
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
21
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
22
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
23
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
24
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
establish correspondence
object
25
pointcut X1(S s1) this(s)
sentence
AspectJFragment ltpointcutsgt List(PointCut)
EOF. PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". List(S)
S. ArgDecl lttgt Type Variable. Type
Ident. Variable Ident.
class dictionary
AspectJFragment ( ltpointcutsgt UNKNOWN-PARSE1
ltfirstgt Nonempty_PointCut_List ( ltitgt
UNKNOWN-PARSE2 ( ltpcnamegt UNKNOWN-PARSE3
( ltidentgt Ident "UNKNOWN-PARSE4" ) ltlhsgt
ArgDecl_PCList ltfirstgt Nonempty_ArgDecl_PCLis
t ( ltitgt UNKNOWN-PARSE5 ( lttgt
UNKNOWN-PARSE6 ( ltidentgt Ident
"UNKNOWN-PARSE7" ) ltvariablegt UNKNOWN-PARSE8
( ltidentgt Ident "UNKNOWN-PARSE9" ) ) )
object
X_List ltfirstgt Nonempty_X_List. Nonempty_X_List
ltitgt X ltnextgt Nonempty_X_List.
26
For phases 3 and 4 List Structure
  • List(X)

first
X_List
Nonempty_X_List
next
it
X
27
pointcut UNKNOWN-PRINT1 (A UNKNOWN-PRINT2,
B UNKNOWN-PRINT3, C c3)
sentence
PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". ArgDecl
lttgt Type Variable. Type Ident. Variable Ident.
class dictionary
ltitgt PointCut ( ltpcnamegt PCName ( ltidentgt
Ident "X3" ) ltlhsgt ArgDecl_PCList ltfirstgt
Nonempty_ArgDecl_PCList ( ltitgt ArgDecl
( lttgt Type ( ltidentgt Ident "A" ) ltvariablegt
Variable ( ltidentgt Ident "a1" ) ) ltnextgt
Nonempty_ArgDecl_PCList (
object
28
pointcut UNKNOWN-PRINT1 (A UNKNOWN-PRINT2,
B UNKNOWN-PRINT3, C c3)
sentence
PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". ArgDecl
lttgt Type Variable. Type Ident. Variable Ident.
class dictionary
ltitgt PointCut ( ltpcnamegt PCName ( ltidentgt
Ident "X3" ) ltlhsgt ArgDecl_PCList ltfirstgt
Nonempty_ArgDecl_PCList ( ltitgt ArgDecl
( lttgt Type ( ltidentgt Ident "A" ) ltvariablegt
Variable ( ltidentgt Ident "a1" ) ) ltnextgt
Nonempty_ArgDecl_PCList (
establish correspondence
object
29
pointcut UNKNOWN-PRINT1 (A UNKNOWN-PRINT2,
B UNKNOWN-PRINT3, C c3)
sentence
PointCut "pointcut" PCName ltlhsgt
PCList(ArgDecl) "" ltrhsgt PCExp "". PCName
Ident. PCList(S) "(" S "," S ")". ArgDecl
lttgt Type Variable. Type Ident. Variable Ident.
class dictionary
ltitgt PointCut ( ltpcnamegt PCName ( ltidentgt
Ident "X3" ) ltlhsgt ArgDecl_PCList ltfirstgt
Nonempty_ArgDecl_PCList ( ltitgt ArgDecl
( lttgt Type ( ltidentgt Ident "A" ) ltvariablegt
Variable ( ltidentgt Ident "a1" ) ) ltnextgt
Nonempty_ArgDecl_PCList (
object
30
Two-way pattern matching
  • Given a pattern and and a use of it, find
    correspondences between pattern and usage.
  • pattern method
  • usage inlined code

31
Iterator it used.iterator() while
(it.hasNext()) Variable curvar
(Variable) it.next() System.out.println()
curvar.print()
static UNKNOWN-ABS3 show(UNKNOWN-ABS4)
UNKNOWN-ABS5 while (it.hasNext())
UNKNOWN-ABS6 System.out.println()
curvar.print()
32
Iterator it used.iterator() while
(it.hasNext()) Variable curvar
(Variable) it.next() System.out.println()
curvar.print()
static UNKNOWN-ABS3 show(UNKNOWN-ABS4)
UNKNOWN-ABS5 while (it.hasNext())
UNKNOWN-ABS6 System.out.println()
curvar.print()
establish correspondence based on context
knowledge
33
Iterator it used.iterator() while
(it.hasNext()) Variable curvar
(Variable) it.next() System.out.println()
curvar.print()
static UNKNOWN-ABS3 show(UNKNOWN-ABS4)
UNKNOWN-ABS5 while (it.hasNext())
UNKNOWN-ABS6 System.out.println()
curvar.print()
establish correspondence based on context
knowledge
34
Iterator it used.iterator() while
(it.hasNext()) Variable curvar
(Variable) it.next() System.out.println()
curvar.print()
static UNKNOWN-ABS3 show(UNKNOWN-ABS4)
UNKNOWN-ABS5 while (it.hasNext())
UNKNOWN-ABS6 System.out.println()
curvar.print()
establish correspondence based on context
knowledge
35
Iterator it used.iterator() while
(it.hasNext()) Variable curvar
(Variable) it.next() System.out.println()
curvar.print()
java.util.Collection used
void
static UNKNOWN-ABS3 show(UNKNOWN-ABS4)
UNKNOWN-ABS5 while (it.hasNext())
UNKNOWN-ABS6 System.out.println()
curvar.print()
establish correspondence
make method as general as possible! Who supports
iterator()?
36
Two-way pattern matching
  • Given a pattern and and a use of it, find
    correspondences between pattern and usage.
  • pattern a programming pattern
  • usage an application in a specific context

37
AspectJFragment // method process finds
all Compound-objects inside // an
AspectJFragment-object and prints the message
// "This is a Compound expression " // for
each Compound-object. void process()
UNKNOWN-AP1 Main.cg.UNKNOWN-AP2(UNKNOWN-AP3,
UNKNOWN-AP4, cV)
CommandVisitor cV new CommandVisitor()
this
"from AspectJFragment to Compound"
38
AspectJFragment // method process finds
all Compound-objects inside // an
AspectJFragment-object and prints the message
// "This is a Compound expression " // for
each Compound-object. void process()
UNKNOWN-AP1 Main.cg.UNKNOWN-AP2(UNKNOWN-AP3,
UNKNOWN-AP4, cV)
CommandVisitor cV new CommandVisitor()
this
"from AspectJFragment to Compound"
DJ programming pattern class-graph.traverse(what,
where-to-go, what-to-do) what an
object where-to-go a traversal
strategy what-to-do a visitor
39
CommandVisitor // prints the message //
"This is a Compound expression " // for each
Compound-object. void UNKNOWN-AP5(UNKNOWN-AP6)
System.out.println("This is a Compound
expression ") host.print()
System.out.println()
40
CommandVisitor // prints the message //
"This is a Compound expression " // for each
Compound-object. void UNKNOWN-AP5(UNKNOWN-AP6)
System.out.println("This is a Compound
expression ") host.print()
System.out.println()
Compound host
Selective visitor pattern Visitor void
before (X host) use host void after
(X host) use host
establish correspondence
41
AspectJFragment // Find all
Variable-objects on the left-hand-side //
(before the colon) of PointCut-objects static
String definedVarsSpec
UNKNOWN-AP7
Answer from AspectJFragment via PointCut via -gt
,lhs, to Variable"
AspectJFragment ltpointcutsgt List(PointCut). Poin
tCut "pointcut" PCName ltlhsgt PCList(ArgDecl)
"" ltrhsgt PCExp "". PCName Ident. PCList(S)
"(" S "," S ")". List(S) S. ArgDecl lttgt
Type Variable. Type Ident. Variable Ident.
42
AspectJFragment // Find all
Variable-objects on the left-hand-side //
(before the colon) of PointCut-objects static
String definedVarsSpec
UNKNOWN-AP7
Answer from AspectJFragment via PointCut via -gt
,lhs, to Variable"
AspectJFragment ltpointcutsgt List(PointCut). Poin
tCut "pointcut" PCName ltlhsgt PCList(ArgDecl)
"" ltrhsgt PCExp "". PCName Ident. PCList(S)
"(" S "," S ")". List(S) S. ArgDecl lttgt
Type Variable. Type Ident. Variable Ident.
43
AspectJFragment // Find all
Variable-objects on the left-hand-side //
(before the colon) of PointCut-objects static
String definedVarsSpec
UNKNOWN-AP7
Answer from AspectJFragment via PointCut via -gt
,lhs, to Variable"
AspectJFragment ltpointcutsgt List(PointCut). Poin
tCut "pointcut" PCName ltlhsgt PCList(ArgDecl)
"" ltrhsgt PCExp "". PCName Ident. PCList(S)
"(" S "," S ")". List(S) S. ArgDecl lttgt
Type Variable. Type Ident. Variable Ident.
44
AspectJFragment // Find all
Variable-objects on the left-hand-side //
(before the colon) of PointCut-objects static
String definedVarsSpec
UNKNOWN-AP7
Answer from AspectJFragment via PointCut via -gt
,lhs, to Variable"
AspectJFragment ltpointcutsgt List(PointCut). Poin
tCut "pointcut" PCName ltlhsgt PCList(ArgDecl)
"" ltrhsgt PCExp "". PCName Ident. PCList(S)
"(" S "," S ")". List(S) S. ArgDecl lttgt
Type Variable. Type Ident. Variable Ident.
45
AspectJFragment // Find all
Variable-objects on the left-hand-side //
(before the colon) of PointCut-objects static
String definedVarsSpec
UNKNOWN-AP7
Answer from AspectJFragment via PointCut via -gt
,lhs, to Variable"
Traversal strategy pattern from A via X via Y to
B
Hint
AspectJFragment ltpointcutsgt List(PointCut). Poin
tCut "pointcut" PCName ltlhsgt PCList(ArgDecl)
"" ltrhsgt PCExp "". PCName Ident. PCList(S)
"(" S "," S ")". List(S) S. ArgDecl lttgt
Type Variable. Type Ident. Variable Ident.
touched by traversal
46
// using an inlined visitor UNKNOWN-AP8 v
UNKNOWN-AP9 // construct a new empty set
HashSet return_val new HashSet()
void UNKNOWN-AP10(Variable v1) return_val.add(v1)
public Object getReturnValue() return
return_val
47
// using an inlined visitor UNKNOWN-AP8 v
UNKNOWN-AP9 // construct a new empty set
HashSet return_val new HashSet()
void UNKNOWN-AP10(Variable v1) return_val.add(v1)
public Object getReturnValue() return
return_val
Selective visitor pattern (inlined) Visitor v
new Visitor // local variable
declarations/definitions void before (X host)
use host void after (X host) use
host public Object getReturnValue()return

48
// in AspectJFragment HashSet
collectVars(String travspec) // using an
inlined visitor UNKNOWN-AP8 v UNKNOWN-AP9
// construct a new empty set
HashSet return_val new HashSet() void
UNKNOWN-AP10(Variable v1) return_val.add(v1)
public Object getReturnValue()return
return_val return (HashSet)
Main.cg.UNKNOWN-AP11(UNKNOWN-AP12,
UNKNOWN-AP13, UNKNOWN-AP14)
travspec
this
v
49
// in AspectJFragment HashSet
collectVars(String travspec) // using an
inlined visitor UNKNOWN-AP8 v UNKNOWN-AP9
// construct a new empty set
HashSet return_val new HashSet() void
UNKNOWN-AP10(Variable v1) return_val.add(v1)
public Object getReturnValue()return
return_val return (HashSet)
Main.cg.UNKNOWN-AP11(UNKNOWN-AP12,
UNKNOWN-AP13, UNKNOWN-AP14)
travspec
this
v
DJ programming pattern class-graph.traverse(what,
where-to-go, what-to-do)
50
Conclusions
  • Now is the time to learn those pattern matching
    skills
  • Use color pens to help your brain detect
    correspondences
  • Final exam will exercise similar skills
  • You will exercise those skills in hw 5 and in the
    project
Write a Comment
User Comments (0)
About PowerShow.com