Skip to content

rquinio/ck2xtext

Repository files navigation

Ck2Xtext Build Status

An Xtext grammar for Crusader Kings 2 modding files.

From some Xtext grammars, the project generates:

  • a bi-directional parser
  • a Java bean model, based on the parsed AST
  • a Language Server implementation, which can easily be embedded as an IDE extension (VSCode, Atom, ...)
  • an Eclipse plugin editor for CK2 files (with colorization, folding, outline, brackets matching, formatter, ...)

Grammars

There are 2 grammars that share some common terminal rules.

GFX grammar

A specific grammar is registered for *.gfx files.

It is complete and successfully validates vanilla files.

Generic grammar

Due to the structure of CK2 scripts, the other grammar is very generic:

  • As files share the same extension (.txt), they have to be managed by a single editor plugin, due to Eclipse extension API not allowing to easily chose an editor based on the file path.
  • As files have no distinctive root elements to indicate their type, it is not possible to describe the CK2 syntax in a single non-ambiguous grammar.

As such the error detection is minimal, and integrated documentation for scripting keywords or functions is inexistent.

Build

To build a clone of this project, the minimum requirements are:

To build locally:

  • From Maven: mvn install
  • From Eclipse: Run-as "MWE2 Workflow" on ck2xtext/src/GenerateCk2.mwe2 (grammar-only)

IDE plugins

Using the Eclipse plugin

To be able to use the plugin, the minimum requirements are:

  • Java 8
  • Eclipse Luna (4.4)

The plugin is not hosted on a public update site yet, and so has to be built locally:

  • Run-as "Eclipse Application" on ck2xtext.ui project
  • Via a local Eclipse update site generated by the build: ck2xtext.repository/target/repository/

Using the Language Server

To start the language server on localhost:5007:

java -jar ck2xtext.ide/target/ck2xtext.ide-1.0.0-SNAPSHOT-ls.jar

For a language client see ck2xtext-vscode extension.