Skip to main content

Getting Started

Dependency​

Start a new project in your favourite IDE and give it a name. I've called mine Aardvark for no particular reason. In most cases your project should have been created with either a build.gradle (Gradle) or pom.xml (Maven) file in the root directory. These represent build automation tools and to which we'll need to add the following dependency:

No build file

If your project does not contain a build file then you may have created a blank project. I'd recommend to either re-create the project and selecting Gradle or Maven, or using one of the starter projects.

build.gradle
dependencies {
implementation 'dev.larf:larf-core:0.89'
}
pom.xml
<dependencies>
<dependency>
<groupId>dev.larf</groupId>
<artifactId>larf-core</artifactId>
<version>0.89</version>
</dependency>
</dependencies>

A projects structure can differ depending on your chosen build tool / IDE, but it should have a structure similar to the following:

[gradle]
[src]
[main]
[java]
[com.aardvark]
Application.java
[test]
...
build.gradle
gradlew
gradlew.bat
settings.gradle

Configuration​

The first thing to do will be to create a configuration file. This is where all your tokens, operators and properties are defined which determine how your language will look and operate. We'll first add a config folder to the structure and put our new class in that:

[src]
[main]
[java]
[com.aardvark]
[config]
AardvarkConfig.java
Application.java

Extending our class from LARFConfig will require us to implement several methods:

public class AardvarkConfig extends LARFConfig {

@Override
protected void initTokenHandlers() { }

@Override
protected void initFunctions() { }

@Override
protected TypeOperation initTypeOperations() { retuurn null; }

@Override
protected void initOperators() { }

@Override
protected void initParserFormatters() { }
}

Don't worry about the content of these methods as we'll get to these in due time.

Runner​

Next we'll modify the existing Application.java file in the root of the project directory. We'll change it to extend another class called LARFRunner* and define the following in the main method:

public class Application extends LARFRunner {

public static void main(String[] args) {
AardvarkConfig config = new AardvarkConfig();
LARFProcessor processor = new LARFProcessor(config);
run("Aardvark Language", processor);
}
}
Runner class

The LARFRunner utility class is runnable allowing you to write, evaluate and test code in your language.

Run the application and you'll be presented with the following:

Aardvark Language Test Utility
==============================

From here you'll be able to evaluate expressions and debug your code. Now that we have the basics sorted, let's get started writing our language.