Extensible Programming and Modeling Languages
Ted Kaminski, Yogesh Mali, August Schwerdfeger and Eric Van Wyk
University of Minnesota
September 20, 2012, Lund, Sweden
Page 1
Extensible Programming and Modeling Languages Ted Kaminski, Yogesh - - PowerPoint PPT Presentation
Extensible Programming and Modeling Languages Ted Kaminski, Yogesh Mali, August Schwerdfeger and Eric Van Wyk University of Minnesota September 20, 2012, Lund, Sweden Page 1 Languages are not monolithic. But most language tools
University of Minnesota
Page 1
◮ Languages are not monolithic. ◮ But most language tools primarily support monolithic design
Page 2
◮ add features to a “host” language — Promela ◮ new language constructs - their syntax and semantics
◮ select (altitude:
◮ select (altitude:
◮ select (altQuality:
◮ DTSpin constructs: timer t; t = 1; expire(t);
◮ new semantics of existing constructs
◮ type checking ◮ advanced ETCH-style type inference and checking Page 3
◮ select (v:
◮ DTSPIN features
◮ as CPP macros — lightweight ◮ or modifying the SPIN implementation — heavyweight
◮ ETCH, enhanced type checking
◮ built their own scanner and parser using SableCC
◮ ableP — middleweight approach
Page 4
◮ enhanced select statements ◮ DTSPIN-like constructs ◮ tabular Boolean expressions (`
Page 5
◮ Users choose (independently developed) extensions. ◮ Tools compose the extensions and Promela host language. ◮ Distinguish
◮ has no knowledge of language design or implementations
◮ must know about language design and implementation
◮ Value easy composition over expressivity, accept some
◮ on syntax ◮ new constructs are translated to “pure” Promela
◮ ableP “instances” are smart pre-processors
Page 6
◮ Extension user directs underlying tools to
◮ compose chosen extensions and the host language ◮ and then create a custom translator for the extended language
◮ Silver grammar modules define sets of specifications
◮ composition is set union, order does not matter
◮ Consider the Silver specification for this composition.
Page 7
◮ context-aware scanning [GPCE07] ◮ modular determinism analysis [PLDI09] ◮ Copper
◮ attribute grammars with forwarding, collections and
◮ set union of specification components ◮ sets of productions, non-terminals, attributes ◮ sets of attribute defining equations, on a production ◮ sets of equations contributing values to a single attribute ◮ modular well-definedness analysis [SLE12] ◮ monolithic termination analysis [SLE12] ◮ Silver Page 8
◮ Scanner recognizes only tokens valid for current “context” ◮ keeps embedded sub-languages, in a sense, separate ◮ Consider:
◮ chan in, out;
◮ Two terminal symbols that match “in”.
◮ terminal IN ’in’ ; ◮ terminal ID /[a-zA-Z ][a-zA-Z 0-9]*/
◮ terminal FOR ’for’ lexer classes {promela kwd }; Page 9
Page 10
Page 11
Page 12
New attributes New productions
Page 13
Page 14
Page 15
Page 16
◮ ∪ of sets of nonterminals, terminals, productions ◮ Composition of all is an context free grammar. ◮ Is it non-ambiguous, useful for deterministic (LR) parsing? ◮ conflictFree(GH ∪ G 1 E ) holds ◮ conflictFree(GH ∪ G 2 E ) holds ◮ conflictFree(GH ∪ G i E) holds ◮ conflictFree(GH ∪ G 1 E ∪ G 2 E ∪ ... ∪ G i E) may not hold
Page 17
◮ ∪ of sets of attributes, attribute equations, occurs-on
◮ Composition of all is an attribute grammar. ◮ Completeness: ∀ production, ∀ attribute, ∃ an equation ◮ complete(AGH ∪ AG 1 E ) holds ◮ complete(AGH ∪ AG 2 E ) holds ◮ complete(AGH ∪ AG i E) holds ◮ complete(AGH ∪ AG 1 E ∪ AG 2 E ∪ ... ∪ AG i E) may not hold ◮ similarly for non-circularity of the AG
Page 18
Page 19
◮ Libraries “just work” ◮ Type checking is done by the library writer, modularly. ◮ Language extensions should be like libraries, composition of
Page 20
◮ isComposable(GH, G 1 E) ∧ conflictFree(GH ∪ G 1 E ) holds ◮ isComposable(GH, G 2 E) ∧ conflictFree(GH ∪ G 2 E ) holds ◮ isComposable(GH, G i E) ∧ conflictFree(GH ∪ G i E) holds ◮ these imply conflictFree(GH ∪ G 1 E ∪ G 2 E ∪ ...) holds ◮ ( ∀i ∈ [1, n].isComposable(GH, G i E) ∧
E)} )
E , . . . , G n E}) ◮ Some restrictions to extension introduced syntax apply, of
Page 21
◮ modComplete(AGH ∪ AG 1 E ) holds ◮ modComplete(AGH ∪ AG 2 E ) holds ◮ modComplete(AGH ∪ AG i E) holds ◮ these imply complete(AGH ∪ AG 1 E ∪ AG 2 E ∪ ...) holds ◮ (∀i ∈ [1, n].modComplete(AG H, AG i E))
E , ..., AG n E}). ◮ similarly for non-circularity of the AG ◮ Again, some restrictions on extensions.
Page 22
◮ ableP supports the simple composition of language extensions ◮ This creates translators and analyzers for customized
◮ extensions can be verified to (syntactically) compose, with
◮ adding (independently developed) extensions that add new
◮ Challenge: SPIN verification still occurs on the generated pure
◮ Future work
◮ More extensions: multi-dimensional array, unit/dimension
◮ Improve type analaysis ◮ Semantic analysis of embedded C code? Page 23
Page 24