RLSRunner and KRunner: Linking Rascal with K for Program Analysis - - PowerPoint PPT Presentation

rlsrunner and krunner linking rascal with k for program
SMART_READER_LITE
LIVE PREVIEW

RLSRunner and KRunner: Linking Rascal with K for Program Analysis - - PowerPoint PPT Presentation

RLSRunner and KRunner: Linking Rascal with K for Program Analysis and Execution Mark Hills, Paul Klint, & Jurgen J. Vinju 2nd International Workshop on the K Framework and its Applications August 9, 2011 Cheile Gradistei, Romania Thursday,


slide-1
SLIDE 1

RLSRunner and KRunner: Linking Rascal with K for Program Analysis and Execution

Mark Hills, Paul Klint, & Jurgen J. Vinju 2nd International Workshop on the K Framework and its Applications August 9, 2011 Cheile Gradistei, Romania

Thursday, June 21, 2012

slide-2
SLIDE 2

Overview

2 Thursday, June 21, 2012

slide-3
SLIDE 3

Overview

  • Motivation

2 Thursday, June 21, 2012

slide-4
SLIDE 4

Overview

  • Motivation
  • Tool components: Rascal

2 Thursday, June 21, 2012

slide-5
SLIDE 5

Overview

  • Motivation
  • Tool components: Rascal
  • Tool components: K

2 Thursday, June 21, 2012

slide-6
SLIDE 6

Overview

  • Motivation
  • Tool components: Rascal
  • Tool components: K
  • Demo

2 Thursday, June 21, 2012

slide-7
SLIDE 7

Overview

  • Motivation
  • Tool components: Rascal
  • Tool components: K
  • Demo
  • Wrap-up

2 Thursday, June 21, 2012

slide-8
SLIDE 8

Motivation: Why This Tool?

3 Thursday, June 21, 2012

slide-9
SLIDE 9

Motivation: Why This Tool?

  • Many K and K in Maude specifications exist -- want reuse

3 Thursday, June 21, 2012

slide-10
SLIDE 10

Motivation: Why This Tool?

  • Many K and K in Maude specifications exist -- want reuse
  • Integrating with graphical environments currently ad-hoc,

bad user experience

3 Thursday, June 21, 2012

slide-11
SLIDE 11

Motivation: Why This Tool?

  • Many K and K in Maude specifications exist -- want reuse
  • Integrating with graphical environments currently ad-hoc,

bad user experience

  • Want a general method to integrate these specifications

with Rascal-based IDEs

3 Thursday, June 21, 2012

slide-12
SLIDE 12

Motivation: Why This Tool?

  • Many K and K in Maude specifications exist -- want reuse
  • Integrating with graphical environments currently ad-hoc,

bad user experience

  • Want a general method to integrate these specifications

with Rascal-based IDEs

  • (Personal) Wanted something like this all during my PhD

3 Thursday, June 21, 2012

slide-13
SLIDE 13

How Should it Work (RLSRunner)?

4 Thursday, June 21, 2012

slide-14
SLIDE 14

How Should it Work (RLSRunner)?

4 Thursday, June 21, 2012

slide-15
SLIDE 15

How Should it Work (RLSRunner)?

4 Thursday, June 21, 2012

slide-16
SLIDE 16

How Should it Work (RLSRunner)?

4 Thursday, June 21, 2012

slide-17
SLIDE 17

How Should it Work (RLSRunner)?

4 Thursday, June 21, 2012

slide-18
SLIDE 18

How Should it Work (RLSRunner)?

4 Thursday, June 21, 2012

slide-19
SLIDE 19

How Should it Work (KRunner)?

5 Thursday, June 21, 2012

slide-20
SLIDE 20

An Introduction to Rascal

  • Rascal: A meta-programming language for source code

analysis and transformation

  • Based on concepts learned from ASF+SDF

, but with a more traditional programming language feel

  • Features: parsing, structured control flow, rich data types

(algebraic data types, lists, sets, tuples, maps, relations, etc), pattern matching, enumerations, higher order functions, etc

6 Thursday, June 21, 2012

slide-21
SLIDE 21

Defining Grammars in Rascal

7 Thursday, June 21, 2012

slide-22
SLIDE 22

Tool Components: Rascal (ShellExec)

PID pid = createProcess(maudeLocation.path); writeTo(pid, toRun); res = readFrom(pid); killProcess(pid);

8

Rascal

Thursday, June 21, 2012

slide-23
SLIDE 23

Tool Components: Rascal (ResourceMarkers)

9

import Message; public void java removeMessageMarkers(loc resourceLoc); public void java addMessageMarkers(set[Message] markers); data Message = error(str msg, loc at) | warning(str msg, loc at) | info(str msg, loc at);

Rascal Rascal

Thursday, June 21, 2012

slide-24
SLIDE 24

Tool Components: Rascal (RLSRunner ADT)

10

data RLSRunner = RLSRun(loc maudeFile, str(str,list[str]) pre, RLSResult(str) post);

Rascal

Thursday, June 21, 2012

slide-25
SLIDE 25

Tool Components: Rascal (Maude-ifier)

11

if ((Program)`<Decl* decls> <FunDecl+ funDecls>` := p) return located(p,"Pgm", "__(<showDecls([d|d<-decls])>, <showFunDecls({f|f<-funDecls})>)"); syntax Program = Default: Decl* decls FunDecl+ funDecls;

Rascal Rascal

Thursday, June 21, 2012

slide-26
SLIDE 26

Tool Components: Rascal (Returning Results)

data RLSResult = SILFAnalysisResult(bool foundErrors, set[Message] messages) ;

12

void exec(Tree pt, loc l) { str pgm = maudeify(pt, true, policy); RLSRunner rlsRunner = RLSRun(silfSpec, pre, post); RLSResult res = runRLSTask(maudeExec, rlsRunner, pgm); if (SILFAnalysisResult(true,msgs) := res) addMessageMarkers(msgs); }

Rascal Rascal

Thursday, June 21, 2012

slide-27
SLIDE 27

Tool Components: Rascal (Generate Program Files)

13

public str generateProgramModule(Tree pgm, str topSort, str pgmName, str pgmMod, str syntaxMod) { set[str] identifiers = { "<id>" | /Id id <- pgm } - "main"; str identifierListing = "syntax Id ::= <intercalate(" | ", [i|i<-identifiers]) > "; str pgmDeclaration = "syntax <topSort> ::= <pgmName>"; return "kmod <pgmMod> is including <syntaxMod> '<identifierListing> '<pgmDeclaration> ' 'macro <pgmName> = ' <pgm> ' 'endkm '"; }

Rascal

Thursday, June 21, 2012

slide-28
SLIDE 28

Tool Components: K (Rascal Source Locations)

fmod RASCAL-LOCATION is including STRING . including INT . sort RLocation .

  • p sl : String Int Int Int Int Int Int -> RLocation .

endfm

14

K/Maude

Thursday, June 21, 2012

slide-29
SLIDE 29

Tool Components: K (Location Semantics)

15

  • p currLoc : RLocation -> State [format (r! o)] .
  • p rloc : RLocation -> ComputationItem .

eq k(rloc(RL) -> K) currLoc(RL') = k(K) currLoc(RL) . eq k(exp(locatedExp(E, RL)) -> K) currLoc(RL') = k(exp(E) -> rloc(RL') -> K) currLoc(RL) .

K/Maude

Thursday, June 21, 2012

slide-30
SLIDE 30

Tool Components: K (Generating Results)

16

  • p makeAnalysisMsg : OutputList -> String .

eq makeAnalysisMsg(warning(level(1) msgloc(RL) msg(S) WIS), OL) = ("||1:::" + rloc2str(RL) + ":::" + S + "||") + makeAnalysisMsg(OL) .

K/Maude

Thursday, June 21, 2012