SlideShare a Scribd company logo
1 of 35
Download to read offline
Lecture 8: Type Constraints
CS4200 Compiler Construction
Hendrik van Antwerpen
TU Delft
September 2018
- Type checking with constraints

- The meta-language NaBL2 to write type specifications

- Examples of different name binding and typing patterns in NaBL2

- Defining the meaning of constraints with constraint semantics
!2
This lecture
Source
Code
Editor
Abstract
Syntax
Tree
ErrorsCollect Constraints SolveParse
Reading Material
3
The following papers add background, conceptual exposition,
and examples to the material from the slides. Some notation and
technical details have been changed; check the documentation.
!4
Type checkers are algorithms that check names and types in programs. 

This paper introduces the NaBL Name Binding Language, which
supports the declarative definition of the name binding and scope rules
of programming languages through the definition of scopes,
declarations, references, and imports associated.
http://dx.doi.org/10.1007/978-3-642-36089-3_18
SLE 2012
Background
!5
This paper introduces scope graphs as a language-independent
representation for the binding information in programs.
http://dx.doi.org/10.1007/978-3-662-46669-8_9
ESOP 2015
Best EAPLS paper at ETAPS 2015
!6
Separating type checking into constraint generation and
constraint solving provides more declarative definition of type
checkers. This paper introduces a constraint language
integrating name resolution into constraint resolution through
scope graph constraints.

This is the basis for the design of the NaBL2 static semantics
specification language.
https://doi.org/10.1145/2847538.2847543
PEPM 2016
!7
Documentation for NaBL2 at the metaborg.org website.
http://www.metaborg.org/en/latest/source/langdev/meta/lang/nabl2/index.html
!8
This paper describes the next generation of the approach.

Addresses (previously) open issues in expressiveness of scope graphs for
type systems:

- Structural types

- Generic types

Addresses open issue with staging of information in type systems.

Introduces Statix DSL for definition of type systems.

Prototype of Statix is available in Spoofax HEAD, but not ready for use in
project yet.
The future
OOPSLA 2018
To appear
Type Checking
with Constraints
9
!10
Source
Code
Editor
Abstract
Syntax
Tree
ErrorsCollect Constraints Solve
Type checking proceeds in two steps
language
specific
language
independent
Parse
What is constraint generation?
- Function that maps a program to constraints

- Defined as a top-down traversal, parameters can be passed down

- Specification of what it means to be well-typed!

What are constraints?
- Logical assertions that should hold for well-typed programs

‣ Logical variables represent unknown values

- Constraint language determines what assertions can be made

‣ Type equality, sub typing, name resolution, ...

- Determines the expressiveness of the specification!

Constraint Solving
- Find an assignment for all logical variables, such that constraints are satisfied

- More on this next week
!11
Typing Constraints
Challenges for type checker implementations?
- Collecting (non-lexical) binding information before use

- Dealing with unknown (type) values

Constraints separate what from how
- Constraint generator + constraint language says what is a well-typed program

- Constraint solver says how to determine that a program is well-typed

Constraints separate computation from program structure
- Constraint generator follows the structure of the program

- Constraint solver is flexible in order of resolution

Constraint naturally support unknown values
- Variables represent unknown values

- Constraint resolution infers appropriate values
!12
Typing Constraints
NaBL2
13
What is NaBL2?
- Domain-specific specification language…
- … to write constraint generators
- Comes with a generic solver
What features does it support?
- Rich binding structures using scope graphs
- Type equality and nominal sub-typing
- Type-dependent name resolution
Limitations
- Restricted to the domain-specific (= restricted) model
‣ Not all name binding patterns in the wild can be expressed
- Hypothesis is that all sensible patterns are expressible
NaBL2
!14
[[ Let(x, e, e') ^ (s) : t' ]] :=
new s', s' -P-> s,
Var{x} <- s', Var{x} : v,
[[ e ^ (s') : t ]],
v == t,
[[ e' ^ (s') : t' ]].
type (optional)
subterm recursion
constraints
scope parametersmatch pattern
Constraint Rules
!15
Tips for writing correct specifications
- Rules have an implicit signature: sort of the matched term, number of scopes, whether it has a type or not
- All rules for terms of a certain sort (e.g., all expression rules) must have the same signature
- All subterm rule invocations must follow the signature of the rules of the subterm sort
- Traverse every term at most once
Scope Graph Constraints
!16
new s // create a new scope
s1 -L-> s2 // edge labeled with L from scope s1 to scope s2
N{x} <- s // x is a declaration in scope s for namespace N
N{x} -> s // x is a reference in scope s for namespace N
N{x} =L=> s // declaration x is associated with scope s
N{x} <=L= s // scope s imports via reference x
N{x} |-> d // reference x resolves to declaration d
[[ e ^ (s) ]] // subterm e is scoped by scoped s
s
s s
N xis
N xi s
N xi s
N xis
N xi N xi
Scope Graph Example
!17
let
var x : int := x + 1
in
x + 1
end
s
s_bodyx
x
Let(
[VarDec(
"x"
, Tid("int")
, Plus(Var("x"), Int("1"))
)]
, [Plus(Var("x"), Int("1"))]
)
[[ Let([VarDec(x, t, e)], [e_body]) ^ (s) ]] :=
new s_body, // new scope
s_body -P-> s, // parent edge to enclosing scope
Var{x} <- s_body, // x is a declaration in s_body
[[ e ^ (s) ]], // init expression
[[ e_body ^ (s_body) ]]. // body expression
[[ Var(x) ^ (s') ]] :=
Var{x} -> s', // x is a reference in s'
Var{x} |-> d, // check that x resolves to a declaration
s’
x
?
P
Name Set Constraints & Expressions
!18
distinct S distinct/name S // elements/names in S are distinct
S1 subseteq S2 S1 subseteq/name S2 // elements/names in S1 are a subset of S2
S1 seteq S2 S1 seteq/name S2 // elements/names in S1 are equal to S2
0 // empty set
D(s) D(s)/N // all/namespace N declarations in s
R(s) R(s)/N // all/namespace N references in s
V(s) V(s)/N // visible declarations in s (w/ shadowing)
W(s) W(s)/N // reachable declarations in s (no shadowing)
(S1 union S2) // union of S1 and S2
(S1 isect S2) (S1 isect/name S2) // intersection of elements/names S1 and S2
(S1 lsect S2) (S1 lsect/name S2) // elements/names in S1 that are in S2
(S1 minus S2) (S1 minus/name S2) // elements/names in S1 that are not in S2
Name Set Examples
!19
s0
s1
s2
Var
x1
Var
x2
Type
y5
Type
y3
Var
x4
D(s0)
D(s1)
W(s1)/Var
R(s2)
(W(s1) minus D(s1)/Var)
V(s1)/Var
(R(s1) lsect/name D(s1))
(R(s1) isect/name D(s1))
Type Constraints
!20
ty1 == ty2 // types ty1 and ty2 are equal
ty1 <R! ty2 // declare ty1 to be related to ty2 in R
ty1 <R? ty2 // require ty1 to be related to ty2 in R
.... // … extensions …
d : ty // declaration d has type ty
[[ e ^ (s) : ty ]] // subterm e has type ty
N xi ty
Type Example
!21
s
s_bodyx
x
[[ Let([VarDec(x, t, e)], [e_body]) ^ (s) : ty' ]] :=
new s_body, // new scope
s_body -P-> s, // parent edge to enclosing scope
Var{x} <- s_body, // x is a declaration in s_body
Var{x} : ty, // associate type
[[ t ^ (s) : ty ]], // type of type
[[ e ^ (s) : ty ]], // type of expression
[[ e_body ^ (s_body) : ty' ]]. // constraints for body
[[ Var(x) ^ (s') : ty ]] :=
Var{x} -> s', // x is a reference in s'
Var{x} |-> d, // check that x resolves to a declaration
d : ty. // type of declaration is type of reference
s’
x
let
var x : int := x + 1
in
x + 1
end
Let(
[VarDec(
"x"
, Tid("int")
, Plus(Var("x"), Int("1"))
)]
, [Plus(Var("x"), Int("1"))]
)
INT
NaBL2 Configuration
!22
signature
namespaces
Var
name resolution
labels P I
order D < P, D < I, I < P
well-formedness P* I*
relations
reflexive, transitive, anti-symmetric sub : Type * Type
Tiger in NaBL2
23
Variable Declarations and References
!24
x1x2 s1
Dec[[ VarDec(x, t, e) ^ (s, s_outer) ]] :=
[[ t ^ (s_outer) ]],
[[ e ^ (s_outer) ]],
Var{x} <- s.
[[ Var(x) ^ (s) ]] :=
Var{x} -> s,
Var{x} |-> d.
s0
s1
s0 Let(
[VarDec("x", INT(), Int("1"))]
, [Plus(Var("x"), Int("1"))]
)
let
var x1 : int := 1
in
x2 + 1
end
s0
s1
s2
let
var x1 : int := 0
in
for i2 := 1 to 4 do
x3 := x4 + i5;
x6 * 7
end
Scoping of Loop Variable
!25
s1 x1
s2 i2x3
i5x4
x6
[[ stm@For(Var(x), e1, e2, e3) ^ (s) ]] :=
new s_for,
s_for -P-> s,
Var{x} <- s_for,
Loop{Break()@stm} <- s_for,
[[ e1 ^ (s) ]],
[[ e2 ^ (s) ]],
[[ e3 ^ (s_for) ]].
s0
let
function pow1(b2 : int, n3 : int) : int =
if n4 < 1
then 1
else (b5 * pow6(b7, n8 - 1))
in
pow9(2, 7)
end
s0
s1
Function Declarations and References
!26
[[ FunDec(f, args, t, e) ^ (s, s_outer) ]] :=
Var{f} <- s,
new s_fun,
s_fun -P-> s,
Map2[[ args ^ (s_fun, s_outer) ]],
distinct/name D(s_fun),
[[ e ^ (s_fun) ]].
[[ FArg(x, t) ^ (s_fun, s_outer) ]] :=
Var{x} <- s_fun,
[[ t ^ (s_outer) ]].
[[ Call(f, exps) ^ (s) ]] :=
Var{f} -> s,
Var{f} |-> d,
Map1[[ exps ^ (s) ]].
s2
s0
s1
s2
pow1pow9
b2
n3
n4
b5
n8
b7
pow6
Sequential Let
!27
s2 x1
s3 y2
s1 z4x5
z7
y6
z3
[[ Let(blocks, exps) ^ (s) ]] :=
new s_body,
Decs[[ blocks ^ (s, s_body) ]],
Seq[[ exps ^ (s_body) ]],
distinct D(s_body).
Decs[[ [] ^ (s_outer, s_body) ]] :=
s_body -P-> s_outer.
Decs[[ [block] ^ (s_outer, s_body) ]] :=
s_body -P-> s_outer,
Dec[[ block ^ (s_body, s_outer) ]].
Decs[[ [block | blocks@[_|_]] ^ (s_outer, s_body) ]] :=
new s_dec,
s_dec -P-> s_outer,
Dec[[ block ^ (s_dec, s_outer) ]],
Decs[[ blocks ^ (s_dec, s_body) ]],
distinct/name D(s_dec).
s0
s0
s2
s3
s1
let
var x1 := 2
var y2 := z3 + 11
var z4 := x5 * y6
in z7 end
Mutually Recursive Functions
!28
s1 odd1 even6
s2
s3
even11
x2
x7odd9
even4
x3
x8
Dec[[ FunDecs(fdecs) ^ (s, s_outer) ]] :=
Map2[[ fdecs ^ (s, s_outer) ]].
[[ FunDec(f, args, t, e) ^ (s, s_outer) ]] :=
new s_fun,
s_fun -P-> s,
distinct/name D(s_fun),
MapTs2[[ args ^ (s_fun, s_outer) ]],
s0
s0
s1
s2
s3
x5
x10
let
function odd1(x2 : int) : int =
if x3 > 0 then even4(x5-1) else 0
function even6(x7 : int) : int =
if x8 > 0 then odd9(x10-1) else 1
in
even11(34)
end
Namespaces
!29
s1
s2
Type
foo1
Var
foo2
Type
foo4
Var
foo5
s3
Var
x3
Var
x6
[[ TypeDec(x, t) ^ (s) ]] :=
[[ t ^ (s) ]],
Type{x} <- s.
[[ VarDec(x, t, e) ^ (s, s_outer) ]] :=
[[ t ^ (s_outer) ]],
[[ e ^ (s_outer) ]],
Var{x} <- s.
s0
s0
s1
s2
s3
let
type foo1 = int
var foo2 : int := 24
var x3 : foo4 := foo5
in
x6
end
Explicit versus Inferred Variable Type
!30
let
var x : int := 20 + 1
var y := 21
in
x + y
end
[[ VarDec(x, t, e) ^ (s, s_outer) ]] :=
[[ t ^ (s_outer) : ty1 ]],
[[ e ^ (s_outer) : ty2 ]],
ty2 <? ty1,
Var{x} <- s,
Var{x} : ty1 !.
[[ VarDecNoType(x, e) ^ (s, s_outer) ]] :=
[[ e ^ (s_outer) : ty ]],
ty != NIL(),
Var{x} <- s,
Var{x} : ty !.
let
type point1 = { x2 : int, y3 : int }
var p4 := point5{ x6 = 4, y7 = 5 }
in
p8.x9
end
s3
Record Definitions
!31
[[ RecordTy(fields) ^ (s) : ty ]] :=
new s_rec,
ty == RECORD(s_rec),
NIL() <! ty,
distinct/name D(s_rec)/Field,
Map2[[ fields ^ (s_rec, s) ]].
[[ Field(x, t) ^ (s_rec, s_outer) ]] :=
Field{x} <- s_rec,
Field{x} : ty !,
[[ t ^ (s_outer) : ty ]].
s0
s2
s1
s0
Type
point1
s1 s2
RECORD(s2)
Field
x2
Field
y3
s3
INT
INT
let
type point1 = { x2 : int, y3 : int }
var p4 := point5{ x6 = 4, y7 = 5 }
in
p8.x9
end
s1
Record Creation
!32
s0
Type
point1
s1 s2
RECORD(s2)
Field
x2
Field
y3
s3
Var
p4
INT
INT
s0
s2
s3
[[ r@Record(t, inits) ^ (s) : ty ]] :=
[[ t ^ (s) : ty ]],
ty == RECORD(s_rec),
new s_use, s_use -I-> s_rec,
D(s_rec)/Field subseteq/name
R(s_use)/Field,
distinct/name R(s_use)/Field,
Map2[[ inits ^ (s_use, s) ]].
[[ InitField(x, e) ^ (s_use, s) ]] :=
Field{x} -> s_use,
Field{x} |-> d,
d : ty1,
[[ e ^ (s) : ty2 ]],
ty2 <? ty1.
s4
Type
point5
s4
Field
x6
Field
y7
s_rec
RECORD(s_rec)
let
type point1 = { x2 : int, y3 : int }
var p4 := point5{ x6 = 4, y7 = 5 }
in
p8.x9
end
s1
Record Field Access
!33
s0
s2
s3
s0
Type
point1
s1 s2
RECORD(s2)
Field
x2
Field
y3
s3
INT
INT
[[ FieldVar(e, f) ^ (s) : ty ]] :=
[[ e ^ (s) : ty_e ]],
ty_e == RECORD(s_rec),
new s_use, s_use -I-> s_rec,
Field{f} -> s_use,
Field{f} |-> d,
d : ty.
s5
RECORD(s2)
Var
p4
Var
p8
s5
Field
x9
s_rec
s4
Full Tiger Specification Online
!34
https://github.com/MetaBorgCube/metaborg-tiger
https://github.com/MetaBorgCube/metaborg-tiger/blob/master/org.metaborg.lang.tiger/trans/static-semantics/static-semantics.nabl2
Except where otherwise noted, this work is licensed under

More Related Content

What's hot

Introduction of bison
Introduction of bisonIntroduction of bison
Introduction of bison
vip_du
 
Introduction of flex
Introduction of flexIntroduction of flex
Introduction of flex
vip_du
 

What's hot (20)

Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
 
Compiler Construction | Lecture 3 | Syntactic Editor Services
Compiler Construction | Lecture 3 | Syntactic Editor ServicesCompiler Construction | Lecture 3 | Syntactic Editor Services
Compiler Construction | Lecture 3 | Syntactic Editor Services
 
Declare Your Language: Type Checking
Declare Your Language: Type CheckingDeclare Your Language: Type Checking
Declare Your Language: Type Checking
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name Resolution
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term Rewriting
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Writing Parsers and Compilers with PLY
Writing Parsers and Compilers with PLYWriting Parsers and Compilers with PLY
Writing Parsers and Compilers with PLY
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Declarative Semantics Definition - Term Rewriting
Declarative Semantics Definition - Term RewritingDeclarative Semantics Definition - Term Rewriting
Declarative Semantics Definition - Term Rewriting
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
 
Declare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesDeclare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) Services
 
Introduction of bison
Introduction of bisonIntroduction of bison
Introduction of bison
 
Introduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesIntroduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented Languages
 
Introduction of flex
Introduction of flexIntroduction of flex
Introduction of flex
 
LEX & YACC TOOL
LEX & YACC TOOLLEX & YACC TOOL
LEX & YACC TOOL
 
Antlr V3
Antlr V3Antlr V3
Antlr V3
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Chapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQChapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQ
 

Similar to Compiler Construction | Lecture 8 | Type Constraints

Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory building
ClarkTony
 
Declare Your Language (at DLS)
Declare Your Language (at DLS)Declare Your Language (at DLS)
Declare Your Language (at DLS)
Eelco Visser
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
monicafrancis71118
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
cargillfilberto
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
drandy1
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)
bolovv
 

Similar to Compiler Construction | Lecture 8 | Type Constraints (20)

Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory building
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Compiler notes--unit-iii
Compiler notes--unit-iiiCompiler notes--unit-iii
Compiler notes--unit-iii
 
Decaf language specification
Decaf language specificationDecaf language specification
Decaf language specification
 
Declare Your Language (at DLS)
Declare Your Language (at DLS)Declare Your Language (at DLS)
Declare Your Language (at DLS)
 
awkbash quick ref for Red hat Linux admin
awkbash quick ref for Red hat Linux adminawkbash quick ref for Red hat Linux admin
awkbash quick ref for Red hat Linux admin
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginners
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)
 
Declarative Thinking, Declarative Practice
Declarative Thinking, Declarative PracticeDeclarative Thinking, Declarative Practice
Declarative Thinking, Declarative Practice
 
Syntaxdirected
SyntaxdirectedSyntaxdirected
Syntaxdirected
 
Syntaxdirected
SyntaxdirectedSyntaxdirected
Syntaxdirected
 
Syntaxdirected (1)
Syntaxdirected (1)Syntaxdirected (1)
Syntaxdirected (1)
 
Metaprogramming in Scala 2.10, Eugene Burmako,
Metaprogramming  in Scala 2.10, Eugene Burmako, Metaprogramming  in Scala 2.10, Eugene Burmako,
Metaprogramming in Scala 2.10, Eugene Burmako,
 
Compilers Design
Compilers DesignCompilers Design
Compilers Design
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)
 
Programming in Scala - Lecture Three
Programming in Scala - Lecture ThreeProgramming in Scala - Lecture Three
Programming in Scala - Lecture Three
 
Learning sed and awk
Learning sed and awkLearning sed and awk
Learning sed and awk
 

More from Eelco Visser

More from Eelco Visser (15)

CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: Introduction
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation Rules
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory Management
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static Analysis
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
Declare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationDeclare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code Generation
 
Declare Your Language: Dynamic Semantics
Declare Your Language: Dynamic SemanticsDeclare Your Language: Dynamic Semantics
Declare Your Language: Dynamic Semantics
 
Declare Your Language: Constraint Resolution 2
Declare Your Language: Constraint Resolution 2Declare Your Language: Constraint Resolution 2
Declare Your Language: Constraint Resolution 2
 
Declare Your Language: Constraint Resolution 1
Declare Your Language: Constraint Resolution 1Declare Your Language: Constraint Resolution 1
Declare Your Language: Constraint Resolution 1
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Recently uploaded (20)

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 

Compiler Construction | Lecture 8 | Type Constraints

  • 1. Lecture 8: Type Constraints CS4200 Compiler Construction Hendrik van Antwerpen TU Delft September 2018
  • 2. - Type checking with constraints - The meta-language NaBL2 to write type specifications - Examples of different name binding and typing patterns in NaBL2 - Defining the meaning of constraints with constraint semantics !2 This lecture Source Code Editor Abstract Syntax Tree ErrorsCollect Constraints SolveParse
  • 3. Reading Material 3 The following papers add background, conceptual exposition, and examples to the material from the slides. Some notation and technical details have been changed; check the documentation.
  • 4. !4 Type checkers are algorithms that check names and types in programs. This paper introduces the NaBL Name Binding Language, which supports the declarative definition of the name binding and scope rules of programming languages through the definition of scopes, declarations, references, and imports associated. http://dx.doi.org/10.1007/978-3-642-36089-3_18 SLE 2012 Background
  • 5. !5 This paper introduces scope graphs as a language-independent representation for the binding information in programs. http://dx.doi.org/10.1007/978-3-662-46669-8_9 ESOP 2015 Best EAPLS paper at ETAPS 2015
  • 6. !6 Separating type checking into constraint generation and constraint solving provides more declarative definition of type checkers. This paper introduces a constraint language integrating name resolution into constraint resolution through scope graph constraints. This is the basis for the design of the NaBL2 static semantics specification language. https://doi.org/10.1145/2847538.2847543 PEPM 2016
  • 7. !7 Documentation for NaBL2 at the metaborg.org website. http://www.metaborg.org/en/latest/source/langdev/meta/lang/nabl2/index.html
  • 8. !8 This paper describes the next generation of the approach. Addresses (previously) open issues in expressiveness of scope graphs for type systems: - Structural types - Generic types Addresses open issue with staging of information in type systems. Introduces Statix DSL for definition of type systems. Prototype of Statix is available in Spoofax HEAD, but not ready for use in project yet. The future OOPSLA 2018 To appear
  • 10. !10 Source Code Editor Abstract Syntax Tree ErrorsCollect Constraints Solve Type checking proceeds in two steps language specific language independent Parse
  • 11. What is constraint generation? - Function that maps a program to constraints - Defined as a top-down traversal, parameters can be passed down - Specification of what it means to be well-typed! What are constraints? - Logical assertions that should hold for well-typed programs ‣ Logical variables represent unknown values - Constraint language determines what assertions can be made ‣ Type equality, sub typing, name resolution, ... - Determines the expressiveness of the specification! Constraint Solving - Find an assignment for all logical variables, such that constraints are satisfied - More on this next week !11 Typing Constraints
  • 12. Challenges for type checker implementations? - Collecting (non-lexical) binding information before use - Dealing with unknown (type) values Constraints separate what from how - Constraint generator + constraint language says what is a well-typed program - Constraint solver says how to determine that a program is well-typed Constraints separate computation from program structure - Constraint generator follows the structure of the program - Constraint solver is flexible in order of resolution Constraint naturally support unknown values - Variables represent unknown values - Constraint resolution infers appropriate values !12 Typing Constraints
  • 14. What is NaBL2? - Domain-specific specification language… - … to write constraint generators - Comes with a generic solver What features does it support? - Rich binding structures using scope graphs - Type equality and nominal sub-typing - Type-dependent name resolution Limitations - Restricted to the domain-specific (= restricted) model ‣ Not all name binding patterns in the wild can be expressed - Hypothesis is that all sensible patterns are expressible NaBL2 !14
  • 15. [[ Let(x, e, e') ^ (s) : t' ]] := new s', s' -P-> s, Var{x} <- s', Var{x} : v, [[ e ^ (s') : t ]], v == t, [[ e' ^ (s') : t' ]]. type (optional) subterm recursion constraints scope parametersmatch pattern Constraint Rules !15 Tips for writing correct specifications - Rules have an implicit signature: sort of the matched term, number of scopes, whether it has a type or not - All rules for terms of a certain sort (e.g., all expression rules) must have the same signature - All subterm rule invocations must follow the signature of the rules of the subterm sort - Traverse every term at most once
  • 16. Scope Graph Constraints !16 new s // create a new scope s1 -L-> s2 // edge labeled with L from scope s1 to scope s2 N{x} <- s // x is a declaration in scope s for namespace N N{x} -> s // x is a reference in scope s for namespace N N{x} =L=> s // declaration x is associated with scope s N{x} <=L= s // scope s imports via reference x N{x} |-> d // reference x resolves to declaration d [[ e ^ (s) ]] // subterm e is scoped by scoped s s s s N xis N xi s N xi s N xis N xi N xi
  • 17. Scope Graph Example !17 let var x : int := x + 1 in x + 1 end s s_bodyx x Let( [VarDec( "x" , Tid("int") , Plus(Var("x"), Int("1")) )] , [Plus(Var("x"), Int("1"))] ) [[ Let([VarDec(x, t, e)], [e_body]) ^ (s) ]] := new s_body, // new scope s_body -P-> s, // parent edge to enclosing scope Var{x} <- s_body, // x is a declaration in s_body [[ e ^ (s) ]], // init expression [[ e_body ^ (s_body) ]]. // body expression [[ Var(x) ^ (s') ]] := Var{x} -> s', // x is a reference in s' Var{x} |-> d, // check that x resolves to a declaration s’ x ? P
  • 18. Name Set Constraints & Expressions !18 distinct S distinct/name S // elements/names in S are distinct S1 subseteq S2 S1 subseteq/name S2 // elements/names in S1 are a subset of S2 S1 seteq S2 S1 seteq/name S2 // elements/names in S1 are equal to S2 0 // empty set D(s) D(s)/N // all/namespace N declarations in s R(s) R(s)/N // all/namespace N references in s V(s) V(s)/N // visible declarations in s (w/ shadowing) W(s) W(s)/N // reachable declarations in s (no shadowing) (S1 union S2) // union of S1 and S2 (S1 isect S2) (S1 isect/name S2) // intersection of elements/names S1 and S2 (S1 lsect S2) (S1 lsect/name S2) // elements/names in S1 that are in S2 (S1 minus S2) (S1 minus/name S2) // elements/names in S1 that are not in S2
  • 19. Name Set Examples !19 s0 s1 s2 Var x1 Var x2 Type y5 Type y3 Var x4 D(s0) D(s1) W(s1)/Var R(s2) (W(s1) minus D(s1)/Var) V(s1)/Var (R(s1) lsect/name D(s1)) (R(s1) isect/name D(s1))
  • 20. Type Constraints !20 ty1 == ty2 // types ty1 and ty2 are equal ty1 <R! ty2 // declare ty1 to be related to ty2 in R ty1 <R? ty2 // require ty1 to be related to ty2 in R .... // … extensions … d : ty // declaration d has type ty [[ e ^ (s) : ty ]] // subterm e has type ty N xi ty
  • 21. Type Example !21 s s_bodyx x [[ Let([VarDec(x, t, e)], [e_body]) ^ (s) : ty' ]] := new s_body, // new scope s_body -P-> s, // parent edge to enclosing scope Var{x} <- s_body, // x is a declaration in s_body Var{x} : ty, // associate type [[ t ^ (s) : ty ]], // type of type [[ e ^ (s) : ty ]], // type of expression [[ e_body ^ (s_body) : ty' ]]. // constraints for body [[ Var(x) ^ (s') : ty ]] := Var{x} -> s', // x is a reference in s' Var{x} |-> d, // check that x resolves to a declaration d : ty. // type of declaration is type of reference s’ x let var x : int := x + 1 in x + 1 end Let( [VarDec( "x" , Tid("int") , Plus(Var("x"), Int("1")) )] , [Plus(Var("x"), Int("1"))] ) INT
  • 22. NaBL2 Configuration !22 signature namespaces Var name resolution labels P I order D < P, D < I, I < P well-formedness P* I* relations reflexive, transitive, anti-symmetric sub : Type * Type
  • 24. Variable Declarations and References !24 x1x2 s1 Dec[[ VarDec(x, t, e) ^ (s, s_outer) ]] := [[ t ^ (s_outer) ]], [[ e ^ (s_outer) ]], Var{x} <- s. [[ Var(x) ^ (s) ]] := Var{x} -> s, Var{x} |-> d. s0 s1 s0 Let( [VarDec("x", INT(), Int("1"))] , [Plus(Var("x"), Int("1"))] ) let var x1 : int := 1 in x2 + 1 end
  • 25. s0 s1 s2 let var x1 : int := 0 in for i2 := 1 to 4 do x3 := x4 + i5; x6 * 7 end Scoping of Loop Variable !25 s1 x1 s2 i2x3 i5x4 x6 [[ stm@For(Var(x), e1, e2, e3) ^ (s) ]] := new s_for, s_for -P-> s, Var{x} <- s_for, Loop{Break()@stm} <- s_for, [[ e1 ^ (s) ]], [[ e2 ^ (s) ]], [[ e3 ^ (s_for) ]]. s0
  • 26. let function pow1(b2 : int, n3 : int) : int = if n4 < 1 then 1 else (b5 * pow6(b7, n8 - 1)) in pow9(2, 7) end s0 s1 Function Declarations and References !26 [[ FunDec(f, args, t, e) ^ (s, s_outer) ]] := Var{f} <- s, new s_fun, s_fun -P-> s, Map2[[ args ^ (s_fun, s_outer) ]], distinct/name D(s_fun), [[ e ^ (s_fun) ]]. [[ FArg(x, t) ^ (s_fun, s_outer) ]] := Var{x} <- s_fun, [[ t ^ (s_outer) ]]. [[ Call(f, exps) ^ (s) ]] := Var{f} -> s, Var{f} |-> d, Map1[[ exps ^ (s) ]]. s2 s0 s1 s2 pow1pow9 b2 n3 n4 b5 n8 b7 pow6
  • 27. Sequential Let !27 s2 x1 s3 y2 s1 z4x5 z7 y6 z3 [[ Let(blocks, exps) ^ (s) ]] := new s_body, Decs[[ blocks ^ (s, s_body) ]], Seq[[ exps ^ (s_body) ]], distinct D(s_body). Decs[[ [] ^ (s_outer, s_body) ]] := s_body -P-> s_outer. Decs[[ [block] ^ (s_outer, s_body) ]] := s_body -P-> s_outer, Dec[[ block ^ (s_body, s_outer) ]]. Decs[[ [block | blocks@[_|_]] ^ (s_outer, s_body) ]] := new s_dec, s_dec -P-> s_outer, Dec[[ block ^ (s_dec, s_outer) ]], Decs[[ blocks ^ (s_dec, s_body) ]], distinct/name D(s_dec). s0 s0 s2 s3 s1 let var x1 := 2 var y2 := z3 + 11 var z4 := x5 * y6 in z7 end
  • 28. Mutually Recursive Functions !28 s1 odd1 even6 s2 s3 even11 x2 x7odd9 even4 x3 x8 Dec[[ FunDecs(fdecs) ^ (s, s_outer) ]] := Map2[[ fdecs ^ (s, s_outer) ]]. [[ FunDec(f, args, t, e) ^ (s, s_outer) ]] := new s_fun, s_fun -P-> s, distinct/name D(s_fun), MapTs2[[ args ^ (s_fun, s_outer) ]], s0 s0 s1 s2 s3 x5 x10 let function odd1(x2 : int) : int = if x3 > 0 then even4(x5-1) else 0 function even6(x7 : int) : int = if x8 > 0 then odd9(x10-1) else 1 in even11(34) end
  • 29. Namespaces !29 s1 s2 Type foo1 Var foo2 Type foo4 Var foo5 s3 Var x3 Var x6 [[ TypeDec(x, t) ^ (s) ]] := [[ t ^ (s) ]], Type{x} <- s. [[ VarDec(x, t, e) ^ (s, s_outer) ]] := [[ t ^ (s_outer) ]], [[ e ^ (s_outer) ]], Var{x} <- s. s0 s0 s1 s2 s3 let type foo1 = int var foo2 : int := 24 var x3 : foo4 := foo5 in x6 end
  • 30. Explicit versus Inferred Variable Type !30 let var x : int := 20 + 1 var y := 21 in x + y end [[ VarDec(x, t, e) ^ (s, s_outer) ]] := [[ t ^ (s_outer) : ty1 ]], [[ e ^ (s_outer) : ty2 ]], ty2 <? ty1, Var{x} <- s, Var{x} : ty1 !. [[ VarDecNoType(x, e) ^ (s, s_outer) ]] := [[ e ^ (s_outer) : ty ]], ty != NIL(), Var{x} <- s, Var{x} : ty !.
  • 31. let type point1 = { x2 : int, y3 : int } var p4 := point5{ x6 = 4, y7 = 5 } in p8.x9 end s3 Record Definitions !31 [[ RecordTy(fields) ^ (s) : ty ]] := new s_rec, ty == RECORD(s_rec), NIL() <! ty, distinct/name D(s_rec)/Field, Map2[[ fields ^ (s_rec, s) ]]. [[ Field(x, t) ^ (s_rec, s_outer) ]] := Field{x} <- s_rec, Field{x} : ty !, [[ t ^ (s_outer) : ty ]]. s0 s2 s1 s0 Type point1 s1 s2 RECORD(s2) Field x2 Field y3 s3 INT INT
  • 32. let type point1 = { x2 : int, y3 : int } var p4 := point5{ x6 = 4, y7 = 5 } in p8.x9 end s1 Record Creation !32 s0 Type point1 s1 s2 RECORD(s2) Field x2 Field y3 s3 Var p4 INT INT s0 s2 s3 [[ r@Record(t, inits) ^ (s) : ty ]] := [[ t ^ (s) : ty ]], ty == RECORD(s_rec), new s_use, s_use -I-> s_rec, D(s_rec)/Field subseteq/name R(s_use)/Field, distinct/name R(s_use)/Field, Map2[[ inits ^ (s_use, s) ]]. [[ InitField(x, e) ^ (s_use, s) ]] := Field{x} -> s_use, Field{x} |-> d, d : ty1, [[ e ^ (s) : ty2 ]], ty2 <? ty1. s4 Type point5 s4 Field x6 Field y7 s_rec RECORD(s_rec)
  • 33. let type point1 = { x2 : int, y3 : int } var p4 := point5{ x6 = 4, y7 = 5 } in p8.x9 end s1 Record Field Access !33 s0 s2 s3 s0 Type point1 s1 s2 RECORD(s2) Field x2 Field y3 s3 INT INT [[ FieldVar(e, f) ^ (s) : ty ]] := [[ e ^ (s) : ty_e ]], ty_e == RECORD(s_rec), new s_use, s_use -I-> s_rec, Field{f} -> s_use, Field{f} |-> d, d : ty. s5 RECORD(s2) Var p4 Var p8 s5 Field x9 s_rec s4
  • 34. Full Tiger Specification Online !34 https://github.com/MetaBorgCube/metaborg-tiger https://github.com/MetaBorgCube/metaborg-tiger/blob/master/org.metaborg.lang.tiger/trans/static-semantics/static-semantics.nabl2
  • 35. Except where otherwise noted, this work is licensed under