1 / 14

Parsing in K-framework

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

evette
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Parsing in K-framework Faculty of Computer Science University of AlexandruIoanCuza, Iași July 2, 2011 RaduMereuță Advisor: Prof. Dorel Lucanu

  2. Outline • About K-framework • Kontributors • Short description • Functionality • Example • Contributions • The parsing technique • Problems • Solution • Conclusion

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

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

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

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

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

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

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

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

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

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

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

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

More Related