280 likes | 424 Views
Building DSLs with Eclipse. Peter Friese, itemis @peterfriese @xtext. (c) 2009 Peter Friese. Distributed under the EDL V1.0 - http://www.eclipse.org/org/documents/edl-v10.php More info: http://www.peterfriese.de / http://www.itemis.co m. Suppose. You’d want to core an apple.
E N D
Building DSLs with Eclipse • Peter Friese, itemis • @peterfriese • @xtext (c) 2009 Peter Friese. Distributed under the EDL V1.0 - http://www.eclipse.org/org/documents/edl-v10.php More info: http://www.peterfriese.de / http://www.itemis.com
? Right tool for the job?
Because you can use it for other stuff, too. E.g., opening a bottle of wine.
BUT avoid the unitasker!
A specific tool for a specific job
A specific tool for a specific job
select name, salary from employees where salary > 2000 order by salary
<project name="MyProject" default="dist" basedir="."> <property name="src" location="src"/> <property name="build" location="build"/> <property name="dist" location="dist"/> <target name="init"> <mkdir dir="${build}"/> </target> <target name="compile" depends="init"> <javac srcdir="${src}" destdir="${build}"/> </target> <target name="dist" depends="compile"> <mkdir dir="${dist}/lib"/> <jar jarfile="${dist}/lib/MyProject.jar" basedir="${build}"/> </target> <target name="clean"> <delete dir="${build}"/> <delete dir="${dist}"/> </target></project>
Create ANTLR grammar • Generate lexer / parser • Parser will create parse tree • Transform parse tree to semantic model • Iterate model • Pass model element(s) to template
Why not use a DSL... ... for building DSLs?