COP 5021 Lecture -*- Outline -*- * Overview of XText ** What is XText? ------------------------------------------ XTEXT OVERVIEW XText is a framework for building DSLs It has built-in ways to do: - lexical analysis - parsing - AST validation - Code generation (or interpretation) Integrated with Xtend, an extension of Java ------------------------------------------ ** installation of Xtext ------------------------------------------ INSTALLATION OF XTEXT 0. Install a Java Runtime Environment, JRE best to get the JDK Development Kit, JDK, from oracle.com/java 1. Install Eclipse eclipse.org/downloads/packages Get the "Eclipse IDE for Java and DSL Developers", from eclipse.org/downloads/packages which has Java, Xtext, and Xtend 2. (If you didn't already Install Xtext) In Eclipse: - Choose Help -> Install New Software... from the menu bar and Add.... - Insert https://download.eclipse.org/ modeling/tmf/xtext/updates/composite/ releases/ as an update site (This site aggregates all components and dependencies of Xtext.) - Select the Xtext SDK from the category Xtext and complete the wizard by clicking the Next button until you can click Finish. - After a quick download and a restart of Eclipse, Xtext is ready to use. ------------------------------------------ I installed JDK 1.21, which is a stable release Note that Eclipse is not in the Microsoft Store ** basic tool usage ------------------------------------------ TYPICAL USAGE OF THE TOOLS 0. Create an XText project choose language name, file suffix, etc. 1. Create Lang.xtext in src folder 2. Generate XText artifacts right click on the .xtext file, select Run As... select "Generate XText Artifacts" 3. Run as Eclipse application to test right click on the main project (edu.ucf.cs.whilelang.WhileLang) select Run As... select Eclipse Application and/or run JUnit tests right click on the ....tests project select Run As... select JUnit Test 4. Edit to enhance the language 5. Repeat the above... ------------------------------------------ ------------------------------------------ OBTAINING WHILELANG FROM GITHUB Clone the WhileLangXtext project from Github In the shell: git clone \ git@github.com:leavens/WhileLangXtext.git or in Eclipse File > Import > Git ... URI is: https://github.com/leavens/ WhileLangXtext.git use main branch clone submodules specify your github.com login (but not the password, need ssh keys) Module structure: edu.ucf.cs.whilelang.WhileLang > src > edu.ucf.cs.whilelang > WhileLang.xtext > ... > edu.ucf.cs.whilelang.generator > WhileLangGenerator.xtend > ... > edu.ucf.cs.whilelang.validation > WhileLangValidator.xtend > ... > ... edu.ucf.cs.whilelang.WhileLang.ide edu.ucf.cs.whilelang.WhileLang.tests > src > edu.ucf.cs.whilelang.tests > ... edu.ucf.cs.whilelang.WhileLang.ui edu.ucf.cs.whilelang.WhileLang.ui.tests ------------------------------------------ Q: What converts the user's input into an AST? The parser