SlideShare a Scribd company logo
1 of 64
Download to read offline
Principled Syntactic Code
Completion using Placeholders
SLE’16 - Amsterdam
Sebastian Erdweg, Guido Wachsmuth, EelcoVisser
Eduardo Souza
2
3
*S. Amann, S. Proksch, S. Nadi, and M. Mezini. A study of visual studio usage in practice. In SANER, 2016.
4
Syntactic Completion
Semantic Completion
5
Syntactic Completion
Semantic Completion
6
Problems
7
Problems
Unsound!
8
Soundness: the resulting program should
have no additional syntax errors.
Problems
9
Problems
Unsound!
10
Incomplete!
Completeness: any program should be derivable
through code completion.
Problems
Unsound!
11
Problems
Incomplete!
Unsound!
12
Ad-hoc!
Problems
Incomplete!
Unsound!
13
Language Specification
Syntax
Definition
Name
Binding
Type
Constraints
Code Completion
Syntactic
Completion
Semantic
Completion
Textual/Projectional IDE
Language Workbenches
14
15
Unsound!
16
Sound and Complete Syntactic
Code Completion from Language
Specifications
17
Language Specification
Syntax
Definition
Name
Binding
Type
Constraints
Code Completion
Syntactic
Completion
Semantic
Completion
Textual IDE
Sound!
Complete!
Language Workbenches
18
Language Specification
SDF3
Name
Binding
Type
Constraints
Code Completion
Syntactic
Completion
Semantic
Completion
Textual IDE
Sound!
Complete!
19
Explicit Placeholders
20
Incomplete
programs
21
Make incompleteness valid using placeholders!
Incomplete
programs
22
23
24
25
26
4
2
3
1
27
Deriving Syntactic Completion from the Syntax Definition
context-free syntax
Statement ::= "if" "(" Exp ")" Statement "else" Statement {"If"}
28
context-free syntax // placeholder rule
Statement ::= “$Statement" {“Statement-Plhdr"}
context-free syntax //regular production rule
Statement ::= "if" "(" Exp ")" Statement "else" Statement {"If"}
Make placeholders part of the language
Stm-Plhdr
If
Exp-Plhdr Stm-Plhdr
29
Stm-Plhdr
context-free syntax //regular production rule
Statement ::= "if" "(" Exp ")" Statement "else" Statement {"If"}
signature constructors // AST signatures
If : Exp * Statement * Statement -> Statement
Calculate placeholder expansions
30
rules
rewrite-placeholder:
Statement-Plhdr() -> If(Exp-Plhdr(), Statement-Plhdr(),
Statement-Plhdr())
Format Expansions
context-free syntax
Statement ::= "if" "(" Exp ")" Statement "else" Statement {cons("If")}
context-free syntax // placeholder rule
Statement ::= "$Statement"
Parse Placeholders
Expand
Placeholders
Incomplete
programs
Complete
programs
Expand
placeholder
Expand/overwrite
placeholders
Correct
programs
31
32
Complete
programs
33
How to expand?
Complete
programs
34
Type a placeholder?
35
Type a placeholder?
36
Type a placeholder?
37
Inferring Placeholders
Optional Parent
List of Statements
38
Add Element to List
Add Optional Element
Placeholder Inference
Optional Parent
List of Statements
Add Optional Element
39
No source region
Add first or last element
Placeholder Inference
Add Element to List
ClassDecl
class “A” {NoParent ConsMethod
[…]
}NilField
40
Placeholder Inference - Optional
41
ClassDecl
class “A” {NoParent ConsMethod
[…]
}NilField
Placeholder Inference - Optional
42
ClassDecl
class “A” {NoParent ConsMethod
[…]
}NilField
Placeholder Inference - Optional
43
Placeholder Inference - Optional
44
Placeholder Inference - Lists
[…]
[…]
Method
Cons
VarDecl
AssignInt “x”
VarRef
“x”
Add
Int
21
Cons
Nil
{ return
[…]
int ;
Int
=
21
45
Placeholder Inference - Lists
[…]
[…]
Method
Cons
VarDecl
AssignInt “x”
VarRef
“x”
Add
Int
21
Cons
Nil
{ return
[…]
int ;
Int
=
21
46
Placeholder Inference - Lists
[…]
[…]
Method
Cons
VarDecl
AssignInt “x”
VarRef
“x”
Add
Int
21
Cons
Nil
{ return
[…]
int ;
Int
=
21
47
Placeholder Inference - Lists
[…]
[…]
Method
Cons
VarDecl
AssignInt “x”
VarRef
“x”
Add
Int
21
Cons
Nil
{ return
[…]
int ;
Int
=
21
48
49
Incomplete
programs
Complete
programs
Expand
placeholder
Infer
placeholder
Correct
programs
Infer
placeholder
Expand/overwrite
placeholders
50
Incorrect
programs
51
Error Recovery
52
53
54
context-free syntax //regular syntax rules
Statement.VarDecl = <<Type> <ID>;>
Statement.Assign = <<VarRef> = <Exp>;>
Insertion Rules
// derived insertion rules for placeholders
context-free syntax
Type.Type-Plhdr = {symbol-insertion}
ID.ID-Plhdr = {symbol-insertion}
Statement.Statement-Plhdr = {symbol-insertion}
VarRef.VarRef-Plhdr = {symbol-insertion}
Exp.Exp-Plhdr = {symbol-insertion}
// derived insertion rules for literals
lexical syntax
"=" = {symbol-completion}
";" = {symbol-completion}
55
Proposal nodes
Insertion nodes
[…]
[…]
Stmt*
amb
VarDecl
ClassType
“x”
VarDecl
[…]
Assign
ID-Plhdr ;
Assign
VarRef
“x”
Exp-Plhdr ;
=
Apply insertion rules at the cursor
56
Limit the search space!
Exp-Plhdr Exp-Plhdr
+
Assign
VarRef
“x”
;
=
[…]
Add
Assign
VarRef
“x”
;=
[…]
Exp-Plhdr
57
Greedy recovery!
[…]
[…]
Stmt*
amb
VarDecl
ClassType
“x”
VarDecl
[…]
Assign
ID-Plhdr ;
Assign
VarRef
“x”
Exp-Plhdr ;
=
58
Nested Proposal Nodes
IntValue Exp-Plhdr+
Assign
VarRef
“x”
;=
[…]
Add
1
59
Incorrect
programs
Incomplete
programs
Complete
programs
Correct
programs
60
Incorrect
programs
Incomplete
programs
Complete
programs
Expand
placeholder
Correct
programs
Expand/overwrite
placeholders
61
Incorrect
programs
Incomplete
programs
Complete
programs
Expand
placeholder
Infer
placeholder
Correct
programs
Infer
placeholder
Expand/overwrite
placeholders
62
Incorrect
programs
Incomplete
programs
Complete
programs
Expand
placeholder
Infer
placeholder
Correct
programs
Infer
placeholder
Expand/overwrite
placeholders
Recover
incomplete
program
Recover
complete
program
63
64
Language Specification
SDF3
Name
Binding
Type
Constraints
Code Completion
Syntactic
Completion
Semantic
Completion
Sound!
Complete!
Textual IDE

More Related Content

Viewers also liked

Rutas argentinas - Serie, Piedra Libre
Rutas argentinas - Serie, Piedra LibreRutas argentinas - Serie, Piedra Libre
Rutas argentinas - Serie, Piedra Libree15de21
 
MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...
MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...
MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...ijbesjournal
 
RED BLOOD CELLS EXTRACTION AND COUNTING
RED BLOOD CELLS EXTRACTION AND COUNTINGRED BLOOD CELLS EXTRACTION AND COUNTING
RED BLOOD CELLS EXTRACTION AND COUNTINGRahul Reghunath
 
Dia de la Bandera - César y Benja
Dia de la Bandera - César y Benja Dia de la Bandera - César y Benja
Dia de la Bandera - César y Benja e15de21
 
Aprendizaje significativo
Aprendizaje significativoAprendizaje significativo
Aprendizaje significativoliliana0213
 
Sociedad de la informacion del conocimiento en la final
Sociedad de la informacion del conocimiento en la finalSociedad de la informacion del conocimiento en la final
Sociedad de la informacion del conocimiento en la finalLina Ayala
 

Viewers also liked (10)

Portfolio Gianfranco Antonaci
Portfolio Gianfranco AntonaciPortfolio Gianfranco Antonaci
Portfolio Gianfranco Antonaci
 
Doobert's Transport Trio
Doobert's Transport TrioDoobert's Transport Trio
Doobert's Transport Trio
 
Course outline
Course outlineCourse outline
Course outline
 
Anato
AnatoAnato
Anato
 
Rutas argentinas - Serie, Piedra Libre
Rutas argentinas - Serie, Piedra LibreRutas argentinas - Serie, Piedra Libre
Rutas argentinas - Serie, Piedra Libre
 
MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...
MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...
MINIMIZATION OF METABOLIC COST OF MUSCLES BASED ON HUMAN EXOSKELETON MODELING...
 
RED BLOOD CELLS EXTRACTION AND COUNTING
RED BLOOD CELLS EXTRACTION AND COUNTINGRED BLOOD CELLS EXTRACTION AND COUNTING
RED BLOOD CELLS EXTRACTION AND COUNTING
 
Dia de la Bandera - César y Benja
Dia de la Bandera - César y Benja Dia de la Bandera - César y Benja
Dia de la Bandera - César y Benja
 
Aprendizaje significativo
Aprendizaje significativoAprendizaje significativo
Aprendizaje significativo
 
Sociedad de la informacion del conocimiento en la final
Sociedad de la informacion del conocimiento en la finalSociedad de la informacion del conocimiento en la final
Sociedad de la informacion del conocimiento en la final
 

Similar to Principled Syntactic Code Completion with Placeholders

Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionEelco Visser
 
Name binding with scope graphs
Name binding with scope graphsName binding with scope graphs
Name binding with scope graphsEelco Visser
 
Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...
Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...
Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...MLconf
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.pptcallroom
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmersamiable_indian
 
LECTURE 6 DESIGN, DEBasd, INTERFACES.pdf
LECTURE 6 DESIGN, DEBasd, INTERFACES.pdfLECTURE 6 DESIGN, DEBasd, INTERFACES.pdf
LECTURE 6 DESIGN, DEBasd, INTERFACES.pdfShashikantSathe3
 
Using ICT to Analyse Language
Using ICT to Analyse LanguageUsing ICT to Analyse Language
Using ICT to Analyse LanguageEka Nathiqo
 

Similar to Principled Syntactic Code Completion with Placeholders (20)

Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
 
Name binding with scope graphs
Name binding with scope graphsName binding with scope graphs
Name binding with scope graphs
 
Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...
Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...
Avi Pfeffer, Principal Scientist, Charles River Analytics at MLconf SEA - 5/2...
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt17
ppt17ppt17
ppt17
 
ppt30
ppt30ppt30
ppt30
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 
ppt18
ppt18ppt18
ppt18
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
 
ppt9
ppt9ppt9
ppt9
 
LECTURE 6 DESIGN, DEBasd, INTERFACES.pdf
LECTURE 6 DESIGN, DEBasd, INTERFACES.pdfLECTURE 6 DESIGN, DEBasd, INTERFACES.pdf
LECTURE 6 DESIGN, DEBasd, INTERFACES.pdf
 
Java
JavaJava
Java
 
Using ICT to Analyse Language
Using ICT to Analyse LanguageUsing ICT to Analyse Language
Using ICT to Analyse Language
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

Principled Syntactic Code Completion with Placeholders