Parsing in k framework
This presentation is the property of its rightful owner.
Sponsored Links
1 / 14

Parsing in K-framework PowerPoint PPT Presentation


  • 90 Views
  • Uploaded on
  • Presentation posted in: General

Parsing in K-framework. Faculty of Computer Science University of Alexandru Ioan Cuza , Ia ș i July 2, 2011. Radu Mereu ță. Advisor: Prof. Dorel Lucanu. Outline. About K-framework Kontributors Short description Functionality Example Contributions The parsing technique Problems

Download Presentation

Parsing in K-framework

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Parsing in k framework

Parsing in K-framework

Faculty of Computer Science

University of AlexandruIoanCuza, Iași

July 2, 2011

RaduMereuță

Advisor: Prof. Dorel Lucanu


Outline

Outline

  • About K-framework

    • Kontributors

    • Short description

    • Functionality

    • Example

  • Contributions

    • The parsing technique

    • Problems

    • Solution

  • Conclusion


Kontributors

Kontributors

  • Joint work between Formal Systems Laboratory (FSL) from University of Illinois at Urbana-Champaign (UIUC) lead by Grigore Roșu and Formal Methods in Software Engineering (FMSE) from Al. I. Cuza University (UAIC) lead by Dorel Lucanu

  • UIUC team:

    Chucky Ellison, Patrick Meredith, Grigore Roșu, Traian Florin Șerbănuță, Andrei Ștefănescu, David Lazăr

  • UAIC team:

    Andrei Arusoaie, Irina Măriuca Asăvoae, Mihai Asăvoae, Gheorghe Grigoraș,Dorel Lucanu, Radu Mereuță, Elena Naum


K framework

K-framework

  • Started by Grigore Roșu in 2003 to teach programming languages

  • Define executable semantics of a programming language

  • Incorporates the advantages of classical approaches

    • Reduction semantics with evaluation contexts

    • Modular SOS (modularity)

    • CHAM (concurrency)

  • Accomplishments:

    • the complete C semantics (Chucky Ellison)

    • Java 1.4 (AzadehFarzan, Feng Chen, Jose Meseguer and Grigore Roșu)

    • Scheme (Patrick Meredith, Mark Hills, and Grigore Roșu)

    • Matching Logic (Elena Naum, GrigoreRoșu and Andrei Ștefănescu)


How do they do it

How Do They Do It?

PDF

Syntax(L)

Latex

PNG

K Definition

EPS

Syntax(K)

Pure K

Maude Interpreter

void main () {

}

configuration

<T>

<k> $PGM </k>

<env> .Map </env>

<in> 1, 2, 3, … </in>

<out> «  » </out>

</T>

Apply K rewrite rules


Example of k definition

Example of K definition

kmod SAMPLE is including BASIC

syntax Exp ::= ID | INT | Exp "+" Exp | Exp "=" Exp

syntaxStm ::= Exp ";" | StmStm

configuration <T> <k> .K </k> <env> .Map </env> </T>

rule [store]:<k> I=V => V:Int </k>

<env> I:Id |-> _ => V </env>

endkm

!!! Problems


Search for a tool

Search for a tool

  • Problems

    • Support for context-free space

    • Lexer ambiguities

    • No support for ambiguous grammars

  • Excluded:

    • ANTLR- LL

    • Gold Parser- LALR

    • LPG (JikesPG)- LALR

  • SDF- context-free


Syntax definition formalism

Syntax Definition Formalism

  • Originates from CWI in the Netherlands

  • Modular syntax definition formalism – easy to extend automatically

  • Scannerless Generalized Parser (JSGLR)

  • Entire context-free space

  • Declarative disambiguation filters

{Exp "*" Exp -> Exp {left, cons("ExpMul")}

Exp "/" Exp -> Exp {left, cons("ExpDiv")}

Exp "%" Exp -> Exp {left, cons("ExpMod")}

} > {

Exp "+" Exp -> Exp {left, cons("ExpPlus")}

Exp "-" Exp -> Exp {left, cons("ExpMinus")}

}


Compilation overview

Compilation overview

  • K definition = syntax (BNF) + semantic (rewrite rules)

Syntax

Semantics

Anno(L)

G1(L)

Generate parser

Disambiguation

G1(D)

Parser

AST

ASF

Pure K

G1(K)

Parsing


Mixing two grammars

Mixing two grammars

K

syntax Exp ::= ID | INT | Exp "+" Exp | Exp "=" Exp

syntaxStm ::= Exp ";" | StmStm

+ subsorting to K

+ variables

+ in place rewriting

+ syntactic rejects

Variable


Parsing problems

Parsing problems

rule <k> X </k> ...

rule(cell("k", K(amb([X:K,

X:Id,

Exp(X:Id),

X:Int,

Exp(X:Int),

X:Exp,

X:Stm,

Id("X"),

Exp(Id("X"))]) ), "k"))


Disambiguation

Disambiguation

  • Extending the disambiguation filter

    • Eliminate anomalies

    • Collect configuration info

      - apply filter for cell types

    • Collect variables declarations

      - apply filter for variables

    • Remove extra subsortings

    • Infer the sort of the remaining variables


Ast to pure k

AST to Pure K

  • Disambiguated AST to Pure K

  • Pure K is the basis for the backend

  • Minimal syntax

    • definition using AST labels

    • Komputations

    • Cells

    • Data structures


Conclusion

Conclusion

  • Contributions

    • Finding a suitable parser

    • Developing a parsing technique

    • Disambiguation algorithm

  • Future work

    • Integration of the parser in K2.0

    • Sort inference

    • Integration with Eclipse


  • Login