- 113 Views
- Uploaded on
- Presentation posted in: General

Parsing in K-framework

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 - - - - - - - - - - - - - - - - - - - - - - - - - -

Parsing in K-framework

Faculty of Computer Science

University of AlexandruIoanCuza, Iași

July 2, 2011

RaduMereuță

Advisor: Prof. Dorel Lucanu

- About K-framework
- Kontributors
- Short description
- Functionality
- Example

- Contributions
- The parsing technique
- Problems
- Solution

- Conclusion

- 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

- 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)

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

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

- 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

- 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")}

}

- 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

K

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

syntaxStm ::= Exp ";" | StmStm

+ subsorting to K

+ variables

+ in place rewriting

+ syntactic rejects

Variable

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"))

- 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

- Disambiguated AST to Pure K
- Pure K is the basis for the backend
- Minimal syntax
- definition using AST labels
- Komputations
- Cells
- Data structures

- 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