parsing in k framework
Download
Skip this Video
Download Presentation
Parsing in K-framework

Loading in 2 Seconds...

play fullscreen
1 / 14

Parsing in K-framework - PowerPoint PPT Presentation


  • 125 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Parsing in K-framework' - evette


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
ad