An Xtext implementation of the PAPLJ language, a simplified Java dialect for teaching Programming And Programming Languages in Java.
The PAPLJ project in Xtext has the following features:
- permissive grammar with operator precedence;
- core library;
- type checking;
- type inference;
- Java class generator.
The Xtext implementation of PAPLJ has some differences when compared to the Spoofax implementation. In the Xtext implementation:
- the syntax is a bit more permissive;
- keywords are not allowed in identifiers;
- casts are written as
x as T
instead of(T)x
; null
is assignable to everything;- everything is assignable to
Any
; run
is optional;
Import the nested existing PAPLJ projects into the workspace of Eclipse with the Xtext 2.11 installed in it.
To run an Eclipse instance with PAPLJ:
- right-click the main project
org.metaborg.paplj
; - select Run As → Eclipse Application to launch the Eclipse instance;
- in the new Eclipse instance, create a new Plug-in Project;
- in the
MANIFEST.MF
, addorg.metaborg.paplj
to the Required Plug-ins dependencies; - in the
src
directory, create a new file ending with the.pj
extension; - if asked, confirm the conversion to an Xtext project.
To run an IntelliJ instance with PAPLJ:
Note: This doesn't currently work as no IntelliJ plugin has been released for Xtext 2.11.
- open the Gradle Tasks view via Window → Show view → Other... → Gradle → Gradle Tasks;
- expand the
org.metaborg.paplj.parent
project; - double-click the
intellij idea/runIdea
task to launch the IntelliJ instance; - create a new Java project - it doesn't need a JDK;
- in the
src
directory, create a new file ending with the.pj
extension.
To run the Web Editor with PAPLJ:
- open the Gradle Tasks view via Window → Show view → Other... → Gradle → Gradle Tasks;
- expand the
org.metaborg.paplj.parent
project; - double-click the
run/jettyRun
task to launch the Jetty server; - open the URL shown in the Console view.
Note: This doesn't load the PAPLJ core library.
The workspace consists of the following projects:
org.metaborg.paplj.parent
— Aggregator build so all modules can be built with one Maven command.org.metaborg.paplj
— The grammar definition and all languge-specific components.org.metaborg.paplj.tests
— Unit-tests for the language.org.metaborg.paplj.ide
— Platform-independent IDE functionality.org.metaborg.paplj.idea
— IntelliJ IDEA functionality.org.metaborg.paplj.ui
— Eclipse functionality.org.metaborg.paplj.ui.tests
— Eclipse unit-tests.org.metaborg.paplj.target
— Eclipse target platform definition against which to build.org.metaborg.paplj.web
— Web functionality.
When changing the Xtext grammar, you need to regenerate the Xtext artifacts:
- open the file
Paplj.xtext
in theorg.metaborg.paplj
package in thesrc
directory of theorg.metaborg.paplj
project; - right-click the grammar editor;
- select Run As → Generate Xtext Artifacts.
To get the guillemets used in Xtend files (that is, «
and »
), in the Eclipse editor press Ctrl+Shift+<, Ctrl+Shift+> (or on Mac Cmd instead of Ctrl).