WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
Scaling Language Specifications
1. Scaling declarative language specifications
to full-featured languages
and real-world applications1
Ted Kaminksi and Eric Van Wyk
University of Minnesota
SLS 2013, June 25, 2013, Cambridge
1
This work is partially supported by NSF Awards No. 0905581 and
1047961.
c Eric Van Wyk 1
4. Scaling up: languages
One strategy:
identify a “core” language
new features translate down to core features
For example:
for-loop to an initializing assignment and while-loop
int x,y,z, to int x; int y; int z;,
Difficult question: Which features are part of the core?
c Eric Van Wyk 4
5. Implicit and explicit specification of semantics
Specify semantics
explictly, where desirable/needed
implicitly, via translation, where possible
ArrayList herd = ... ;
for (Goat g: herd) {
g.milk ();
}
language feature-specific
error messages, analysis
optimizations
from Java 1.5 translates to code in Java 1.4:
ArrayList herd = ... ;
for (Iterator it = herd.iterator(); it.hasNext();) {
Goat g = (Goat) it.next(); g.milk();
}
for byte code generation
c Eric Van Wyk 5
6. Forwarding
supports explicit and implicit (via translation)
specification of semantics
originated in Intentional Programming at MSR Redmond,
adapted to attribute grammars at Oxford [CC’02]
In attribute grammar terminology:
production define some attributes
construct a semantically equivalent syntax tree and
“forward” queries for undefined attributes to that tree
Similar to prototype or object inheritance, not class
inheritance.
c Eric Van Wyk 6
7. abstract production enhanced for
f::Stmt ::= ’for’ ’(’ t::Type id::Id ’:’ data::Expr ’)’
body::Stmt
{ f.errors = if isCollection || isArray then [ ]
else [ "Enhanced-for must iterate over " ++
"Collections or arrays." ];
data.env = addEnv( id, t.typerep, f.env ) ;
local attribute isCollection :: Boolean =
match( data.typerep, collectionType( ) ) ;
local attribute isArray :: Boolean =
match( data.typerep, arrayTypeRep( ) ) ;
forwards to if isCollection then forOverCollection
else if isArray then forOverArray
else skip() ;
local attribute forOverCollection :: Stmt =
... syntax tree of for-loop over a collection...
local attribute forOverArray :: Stmt =
... syntax tree of for-loop over an array...
}c Eric Van Wyk 7
8. Various uses
Name binding
production unboundVarRef
e::Expr ::= v::VarRef t
forwards to
production boundVarRef
e::Expr ::= v::VarRef t dcl::Decorated Dcl
operator overloading
generic addition
forwards to
type-specific addition (e.g. integer, matrix, ... )
c Eric Van Wyk 8
10. Extensible Languages (Frameworks)
@MSR: Intentional Programming
@Minnesota: ableJ [ECOOP’07], ableP [SPIN’11]
pluggable domain-specific language extensions
domain-specific syntax, analysis, and optimization
composable, developed independently!
general purpose host language still available
Extension features translate down to host language
c Eric Van Wyk 10
11. class Demo {
int demoMethod ( ) {
List<List<Integer>> dlist ;
int T ;
int SELECT ;
connection c "jdbc:derby:/home/derby/db/testdb"
with table person [ person id INTEGER,
first name VARCHAR,
last name VARCHAR ] ,
table details [ person id INTEGER,
age INTEGER ] ;
Integer limit = 18 ;
ResultSet rs = using c query {
SELECT age, gender, last name
FROM person , details
WHERE person.person id = details.person id
AND details.age > limit } ;
Integer = rs.getInteger("age");
String gender = rs.getString("gender");
boolean b ;
b = table ( age > 40 : T * ,
gender == "M" : T F ) ;
}
}
• natural syntax
• semantic analysis
• composable extensions
• SQL queries
• non-null pointer
analysis
• tabular boolean
expressions
c Eric Van Wyk 11
16. Extensible languages require declarative
specifications
Composable language/extension specifications.
For composable (no glue code) extensions, forwarding is
needed.
These make extensible language possible, but don’t
esnure that the extensions will, in fact, compose.
modular analysis are needed.
c Eric Van Wyk 16
17. Building a parser from composed specifications.
... CFGH
∪∗
{CFGE1
, ..., CFGEn
}
∀i ∈ [1, n].isComposable(CFGH
, CFGEi
)∧
conflictFree(CFGH
∪ CFGEi
)
⇒ ⇒ conflictFree(CFGH
∪ {CFGE1
, ..., CFGEn
})
Monolithic analysis - not too hard, but not too useful.
Modular analysis - harder, but required [PLDI’09].
Non-commutative composition of restricted LALR(1)
grammars.
c Eric Van Wyk 17
18. Building an attribute grammar evaluator from composed
specifications.
... AGH
∪∗
{AGE1
, ..., AGEn
}
∀i ∈ [1, n].modComplete(AGH
, AGEi
)
⇒ ⇒ complete(AGH
∪ {AGE
1 , ..., AGE
n })
Monolithic analysis - not too hard, but not too useful.
Modular analysis - harder, but required [SLE’12a].
c Eric Van Wyk 18
20. Future work
#include <sdtio.h>
int main() {
... bits of SAC ...
... stencil specifications ...
... computational geometry optimizations
robustness transformations ...
}
c Eric Van Wyk 20
21. Thanks for your attention.
Questions?
http://melt.cs.umn.edu
evw@cs.umn.edu
c Eric Van Wyk 21
22. E. Van Wyk, O. de Moor, K. Backhouse, and
P. Kwiatkowski.
Forwarding in attribute grammars for modular language
design.
In 11th Conf. on Compiler Construction (CC), volume
2304 of LNCS, pages 128–142. Springer-Verlag, 2002.
Eric Van Wyk, Lijesh Krishnan, August Schwerdfeger, and
Derek Bodin.
Attribute grammar-based language extensions for Java.
In Proc. of European Conf. on Object Oriented Prog.
(ECOOP), volume 4609 of LNCS, pages 575–599.
Springer-Verlag, 2007.
c Eric Van Wyk 21
23. Yogesh Mali and Eric Van Wyk.
Building extensible specifications and implementations of
promela with AbleP.
In Proc. of Intl. SPIN Workshop on Model Checking of
Software, volume 6823 of LNCS, pages 108–125.
Springer-Verlag, July 2011.
August Schwerdfeger and Eric Van Wyk.
Verifiable composition of deterministic grammars.
In Proc. of Conf. on Programming Language Design and
Implementation (PLDI), pages 199–210. ACM, June 2009.
Ted Kaminski and Eric Van Wyk.
Modular well-definedness analysis for attribute grammars.
In Proc. of Intl. Conf. on Software Language Engineering
(SLE), volume 7745 of LNCS, pages 352–371.
Springer-Verlag, September 2012.
c Eric Van Wyk 21
24. Lijesh Krishnan and Eric Van Wyk.
Termination analysis for higher-order attribute grammars.
In Proceedings of the 5th International Conference on
Software Language Engineering (SLE 2012), volume 7745
of LNCS, pages 44–63. Springer-Verlag, September 2012.
Lijesh Krishnan.
Composable Semantics Using Higher-Order Attribute
Grammars.
PhD thesis, University of Minnesota, Department of
Computer Science and Engineering, Minneapolis,
Minnesota, USA, 2012.
Available at
http://melt.cs.umn.edu/pubs/krishnan2012PhD/.
c Eric Van Wyk 21