* [[http://www.yinwang.org/blog-cn/2015/09/19/parser|谈谈Parser]] * [[http://www.yinwang.org/blog-cn/2013/04/20/editor-ide|编辑器与IDE]] * [[wp>Language workbench]] * [[wp>JetBrains MPS]] * [[wp>Xtext]] * [[http://www.languageworkbenches.net/|Language Workbench Challenge]] * [[https://blogs.msdn.microsoft.com/kirillosenkov/2009/09/09/first-videos-of-the-structured-editor-prototype/|First videos of the structured editor prototype]] * [[http://stackoverflow.com/questions/2603134/what-are-the-main-differences-between-jetbrains-mps-and-eclipse-xtext|What are the main differences between Jetbrains' MPS and Eclipse Xtext?]] ====== MPS ====== {{http://www.osenkov.com/diplom/contents/1/3/index_clip_image004.gif}} * [[https://www.jetbrains.com/mps/concepts/|How Does MPS Work?]] * 不以文本表示程序語言,省略剖析的部分,直接對 AST 操作。 * [[wp>Structure editor]] * 又稱 [[http://martinfowler.com/bliki/ProjectionalEditing.html|Projectional Editing]],相對於傳統的 [[wp>Source code editor]] (直接撰寫程序文本,又稱 [[http://martinfowler.com/bliki/SourceEditing.html|Source Editing]])。所謂的 projectional,是指將編輯的 AST 投影成程序文本 (也就是我們在 source code editor 編輯的部分)。注意! 我們存檔的時候,是將 AST 存起來,而不是程序文本。 * [[https://www.youtube.com/watch?v=iN2PflvXUqQ|MPS Projectional Editor]] * [[https://confluence.jetbrains.com/display/MPSD32/Fast+Track+to+MPS|Fast Track to MPS]] * [[https://confluence.jetbrains.com/display/MPSD33/MPS+User's+Guide|MPS User's Guide]] ====== Xtext ====== 基本上我們是撰寫 xtext 語法,再經由 xtext 編譯器: * 產生 antlr grammer,調用 antlr 工具產生 parser。 * 產生 emf,產生 IDE 組件。 * [[http://stackoverflow.com/questions/8672144/whats-the-relationshiop-between-xtext-and-antlr|What's the relationshiop between Xtext and ANTLR?]] * [[http://stackoverflow.com/questions/14419244/xtext-relation-between-ast-metamodel-and-parse-tree|xtext: Relation between AST, Metamodel and parse tree]] * [[http://www.infoq.com/interviews/sven-efftinge-xtend-xtext|Interview with Sven Efftinge on Xtend and Xtext]] * [[http://tomassetti.me/develop-dsls-for-eclipse-and-intellij/|Develop DSLs for Eclipse and IntelliJ using Xtext]] * [[http://www.slideshare.net/sefftinge/xtext-webinar-1726480|Xtext Webinar]] * [[http://www.slideshare.net/schwurbel/pragmatic-dsl-design-with-xtext-xbase-and-xtend-2|Pragmatic DSL Design with Xtext, Xbase and Xtend 2]] * [[http://pettergraff.blogspot.tw/2009/11/xtext-vs-emftext-development-process.html|Xtext vs. EMFText: Development Process]] * [[https://eclipse.org/Xtext/documentation/index.html|Xtext Documentation]] * [[https://eclipse.org/Xtext/documentation/301_grammarlanguage.html|The Grammar Language]] * linking phase: 符號解析 (symbol resolution)。 * parse tree: node model, instance of EMF ECore Model。 * abstract syntax tree: semantic model。 ===== ANTLR ===== * [[http://www.antlr.org/|ANTLR]] * [[https://github.com/antlr/antlr4/blob/master/doc/index.md|ANTLR 4 Documentation]] * [[https://github.com/antlr/antlr4/blob/master/doc/getting-started.md|Getting Started with ANTLR v4]] * [[http://stackoverflow.com/questions/1931307/antlr-is-there-a-simple-example|ANTLR: Is there a simple example?]] * [[http://www.theendian.com/blog/antlr-4-lexer-parser-and-listener-with-example-grammar/|ANTLR 4: using the lexer, parser and listener with example grammar]] * 相對於 Yacc 產生 LALR (bottom-up) parser,ANTLR 會產生 LL (top-down) parser,即 recursive decent parser。 * ANTLR 4 預設採用 listener (callback) 方式,遍歷抽象語法樹,執行到某條規則時,即會調用使用者自己定義的 listener 函式。可以改回 ANTLR 3 以前採用的 visitor 方式。 * lexer 和 parser 的規則寫在單一檔案,*.g4 檔。lexer 規則開頭大寫,parser 規則開頭小寫。