Implementing Domain Specific Languages with Xtext and Xtend - Second Edition

Lorenzo Bettini

買這商品的人也買了...

商品描述

Learn how to implement a DSL with Xtext and Xtend using easy-to-understand examples and best practices

About This Book

  • Leverage the latest features of Xtext and Xtend to develop a domain-specific language.
  • Integrate Xtext with popular third party IDEs and get the best out of both worlds.
  • Discover how to test a DSL implementation and how to customize runtime and IDE aspects of the DSL

Who This Book Is For

This book is targeted at programmers and developers who want to create a domain-specific language with Xtext. They should have a basic familiarity with Eclipse and its functionality. Previous experience with compiler implementation can be helpful but is not necessary since this book will explain all the development stages of a DSL.

What You Will Learn

  • Write Xtext grammar for a DSL;
  • Use Xtend as an alternative to Java to write cleaner, easier-to-read, and more maintainable code;
  • Build your Xtext DSLs easily with Maven/Tycho and Gradle;
  • Write a code generator and an interpreter for a DSL;
  • Explore the Xtext scoping mechanism for symbol resolution;
  • Test most aspects of the DSL implementation with JUnit;
  • Understand best practices in DSL implementations with Xtext and Xtend;
  • Develop your Xtext DSLs using Continuous Integration mechanisms;
  • Use an Xtext editor in a web application

In Detail

Xtext is an open source Eclipse framework for implementing domain-specific languages together with IDE functionalities. It lets you implement languages really quickly; most of all, it covers all aspects of a complete language infrastructure, including the parser, code generator, interpreter, and more.

This book will enable you to implement Domain Specific Languages (DSL) efficiently, together with their IDE tooling, with Xtext and Xtend. Opening with brief coverage of Xtext features involved in DSL implementation, including integration in an IDE, the book will then introduce you to Xtend as this language will be used in all the examples throughout the book. You will then explore the typical programming development workflow with Xtext when we modify the grammar of the DSL.

Further, the Xtend programming language (a fully-featured Java-like language tightly integrated with Java) will be introduced. We then explain the main concepts of Xtext, such as validation, code generation, and customizations of runtime and UI aspects. You will have learned how to test a DSL implemented in Xtext with JUnit and will progress to advanced concepts such as type checking and scoping. You will then integrate the typical Continuous Integration systems built in to Xtext DSLs and familiarize yourself with Xbase. By the end of the book, you will manually maintain the EMF model for an Xtext DSL and will see how an Xtext DSL can also be used in IntelliJ.

Style and approach

A step-by step-tutorial with illustrative examples that will let you master using Xtext and implementing DSLs with its custom language, Xtend.

商品描述(中文翻譯)

學習如何使用Xtext和Xtend實現DSL,並使用易於理解的示例和最佳實踐。

關於本書:
- 利用Xtext和Xtend的最新功能開發特定領域語言。
- 將Xtext與流行的第三方IDE集成,充分發揮雙方的優勢。
- 了解如何測試DSL實現以及如何自定義DSL的運行時和IDE方面。

本書適合對使用Xtext創建特定領域語言的程序員和開發人員。他們應該對Eclipse及其功能有基本的熟悉。雖然對編譯器實現有先前經驗可能有幫助,但不是必需的,因為本書將解釋DSL的所有開發階段。

你將學到:
- 為DSL編寫Xtext語法;
- 使用Xtend作為Java的替代方案,編寫更清晰、易於閱讀和易於維護的代碼;
- 使用Maven/Tycho和Gradle輕鬆構建你的Xtext DSL;
- 為DSL編寫代碼生成器和解釋器;
- 探索Xtext的作用域機制以進行符號解析;
- 使用JUnit測試DSL實現的大部分方面;
- 了解使用Xtext和Xtend實現DSL的最佳實踐;
- 使用持續集成機制開發你的Xtext DSL;
- 在Web應用程序中使用Xtext編輯器。

Xtext是一個開源的Eclipse框架,用於實現特定領域語言以及IDE功能。它讓你能夠快速實現語言,最重要的是,它涵蓋了完整的語言基礎設施,包括解析器、代碼生成器、解釋器等。

本書將使你能夠使用Xtext和Xtend高效地實現特定領域語言及其IDE工具。首先簡要介紹涉及DSL實現的Xtext功能,包括在IDE中的集成,然後介紹Xtend,因為本書中的所有示例都將使用該語言。然後,你將探索使用Xtext修改DSL語法時的典型編程開發工作流程。

此外,將介紹Xtend編程語言(一種與Java緊密集成的功能完整的類似Java的語言)。然後解釋Xtext的主要概念,如驗證、代碼生成和運行時和UI方面的自定義。你將學習如何使用JUnit測試在Xtext中實現的DSL,並進一步了解類型檢查和作用域等高級概念。然後將集成內置於Xtext DSL中的典型持續集成系統,並熟悉Xbase。在本書結束時,你將手動維護Xtext DSL的EMF模型,並了解如何在IntelliJ中使用Xtext DSL。

風格和方法:
這是一本逐步教程,具有實例,讓你掌握使用Xtext和實現DSL的自定義語言Xtend。