Skip to content

Commit

Permalink
Merge branch 'develop' into master for 0.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLandau committed Jun 8, 2015
2 parents 3e6f8f1 + b5aa4c2 commit 463a24c
Show file tree
Hide file tree
Showing 90 changed files with 5,265 additions and 2 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Alex Landau

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,77 @@
# griddle
GDL validation and Eclipse GDL editor plugin.

Still under development, nothing to see here yet...
Griddle is an Eclipse plugin offering a lightweight editor for the Game Description Language (GDL) used in General Game Playing. It uses its own library for parsing and validating GDL to keep its dependencies (and memory footprint) minimal.

The Griddle editor offers the following features:

- Syntax highlighting
- Errors and warnings for syntax mistakes and other potential problems
- Indentation assistance

Additional features that may be included in the future:

- Configuration of errors and warnings, including support for GDL-II and other proposed changes to GDL
- One-step reformatting or indentation correction for the entire file
- Build system improvements (see "Building from source" below)

Other possible features that won't happen unless there's evidence of demand:

- Improved support for the validation library as a stand-alone library
- CLI for validation and error detection
- Customization of syntax highlighting colors

Installation
------------

The plugin can be applied to an existing Eclipse installation using the following steps (older versions of Eclipse may need a different approach):

1. Download the .jar file containing the plugin from the Github repository's Releases section: https://github.com/AlexLandau/griddle/releases
2. Locate the directory containing your Eclipse installation; this should include files like eclipse.ini and folders like features, plugins, and dropins.
3. Add a folder named plugins to the dropins folder (or use an existing one if it's already there).
4. Put the .jar file into the dropins folder.
5. Restart Eclipse.

If the installation was successful, .kif and .gdl files will be displayed with a black chess knight icon and can be opened in a "GDL Editor" that includes syntax highlighting. However, errors and warnings will not work until enabled:

1. Right-click on the project containing the GDL files.
2. In the "Configure" submenu, click "Add GDL Validation".

If "Build Automatically" is checked in the "Project" menu, errors and warnings will be recomputed each time the file is saved.

Feature notes
-------------

Errors and warnings are based on the 2008 version of the original Game Description Language specification, as well as my own experiences with writing games and general game players. Direct contradictions of the specification and problems that will reliably cause players to break are generally errors, while gray areas and issues that less commonly cause problems are left as warnings.

Note that several requirements for well-formed games, such as termination and having well-formed goal values, cannot be checked by examination of the game description alone. Files with no errors or warnings in Griddle may still be invalid games or contain bugs. The Validator application in the GGP-Base library can check for these errors, though by their nature these types of errors can escape detection.

For first-time guidance on writing and testing game descriptions, I recommend my blog post on the subject: http://alloyggp.blogspot.com/2013/01/writing-game-with-gdl-sim.html

Griddle supports the indentation method of four spaces per level of parenthetical nesting. This has the nice property of having arguments for the <= and "or" operators aligned, and, unlike tabs, does this consistently across platforms.

Working on the source files
---------------------------

There are two separate projects: the "net.alloyggp.griddle" project, which is an Eclipse plugin project (developed using Eclipse PDE), and the validation project, which is an ordinary Java project.

The net.alloyggp.griddle project contains Eclipse project files, and can be imported into Eclipse as an existing project. It may not function correctly or may appear to be missing referenced classes until additional Eclipse components have been installed, such as the Eclipse Plug-in Development Environment and Eclipse Platform SDK.

Eclipse project files for the validation project can be generated by running "./gradlew eclipse" or, on Windows, ".\gradlew.bat eclipse".

The GdlScanner and GdlParser classes are generated by the JFlex and CUP libraries, respectively. Modifications to these classes should be made by modifying the appropriate file in the schemas directory and then running the runCup or runFlex script file (in the main project directory).

Building from source
--------------------

This is a process that needs to be improved and automated eventually. For now:

1. Build the validation project using "./gradlew build" (on Windows, ".\gradlew.bat build").
2. Copy the validation-<version>.jar file from validation/build/libs to the net.alloyggp.griddle directory.
3. Refresh the net.alloyggp.griddle project folder in Eclipse.
4. Export the project in Eclipse with the "Plug-in Development/Deployable plug-ins and fragments" wizard.

Authorship
----------

Griddle is written and maintained by Alex Landau. Email may be directed to [email protected], but consider first if the "Issues" section of the Github repository is more applicable.
9 changes: 9 additions & 0 deletions net.alloyggp.griddle/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="java-cup-11b-runtime.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="validation-0.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions net.alloyggp.griddle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
28 changes: 28 additions & 0 deletions net.alloyggp.griddle/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net.alloyggp.griddle</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions net.alloyggp.griddle/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
16 changes: 16 additions & 0 deletions net.alloyggp.griddle/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Griddle
Bundle-SymbolicName: net.alloyggp.griddle;singleton:=true
Bundle-Version: 0.1.0.qualifier
Bundle-Activator: net.alloyggp.griddle.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.ui.editors,
org.eclipse.core.resources;bundle-version="3.9.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: validation-0.1.jar,
java-cup-11b-runtime.jar,
.
9 changes: 9 additions & 0 deletions net.alloyggp.griddle/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
validation-0.1.jar,\
java-cup-11b-runtime.jar
jars.compile.order = .
Binary file added net.alloyggp.griddle/icons/knight.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added net.alloyggp.griddle/icons/sample.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added net.alloyggp.griddle/java-cup-11b-runtime.jar
Binary file not shown.
46 changes: 46 additions & 0 deletions net.alloyggp.griddle/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

<extension
point="org.eclipse.ui.editors">
<editor
name="GDL Editor"
extensions="kif"
icon="icons/knight.gif"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
class="net.alloyggp.griddle.editors.GdlEditor"
id="net.alloyggp.griddle.editors.GdlEditor">
</editor>
</extension>
<extension
point="org.eclipse.ui.editors.documentProviders">
<provider
class="org.eclipse.ui.editors.text.TextFileDocumentProvider"
id="org.eclipse.ui.editors.text.StorageDocumentProvider">
</provider>
</extension>
<extension
id="gdlValidator" name="GDL Validator" point="org.eclipse.core.resources.builders">
<builder>
<run class="net.alloyggp.griddle.builder.GdlBuilder">
<parameter name="optimize" value="true" />
</run>
</builder>
</extension>
<extension point="org.eclipse.ui.commands">
<command defaultHandler="net.alloyggp.griddle.builder.AddBuilder" id="net.alloyggp.griddle.addBuilder" name="Add GDL Validation">
</command>
<command defaultHandler="net.alloyggp.griddle.builder.RemoveBuilder" id="net.alloyggp.griddle.removeBuilder" name="Remove GDL Validation">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution allPopups="false" locationURI="popup:org.eclipse.ui.projectConfigure?after=additions">
<command commandId="net.alloyggp.griddle.addBuilder" style="push">
</command>
<command commandId="net.alloyggp.griddle.removeBuilder" style="push">
</command>
</menuContribution>
</extension>

</plugin>
63 changes: 63 additions & 0 deletions net.alloyggp.griddle/src/net/alloyggp/griddle/Activator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package net.alloyggp.griddle;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {

// The plug-in ID
public static final String PLUGIN_ID = "net.alloyggp.griddle"; //$NON-NLS-1$

// The shared instance
private static Activator plugin;

/**
* The constructor
*/
public Activator() {
}

/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}

/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}

/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}

/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package net.alloyggp.griddle.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;

/*
* Note: Much of this code was lifted from the tutorial at
* http://codeandme.blogspot.com/2012/10/integrating-custom-builder.html
*/
public class AddBuilder extends AbstractHandler implements IHandler {

@Override
public Object execute(final ExecutionEvent event) {
final IProject project = getProject(event);

if (project != null) {
try {
// verify already registered builders
if (hasBuilder(project)) {
// already enabled
return null;
}

// add builder to project properties
IProjectDescription description = project.getDescription();
final ICommand buildCommand = description.newCommand();
buildCommand.setBuilderName(GdlBuilder.BUILDER_ID);

final List<ICommand> commands = new ArrayList<ICommand>();
commands.addAll(Arrays.asList(description.getBuildSpec()));
commands.add(buildCommand);

description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
project.setDescription(description, null);

} catch (final CoreException e) {
// TODO could not read/write project description
e.printStackTrace();
}
}

return null;
}

public static IProject getProject(final ExecutionEvent event) {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
final Object element = ((IStructuredSelection) selection).getFirstElement();

return (IProject) Platform.getAdapterManager().getAdapter(element, IProject.class);
}

return null;
}

public static final boolean hasBuilder(final IProject project) {
try {
for (final ICommand buildSpec : project.getDescription().getBuildSpec()) {
if (GdlBuilder.BUILDER_ID.equals(buildSpec.getBuilderName()))
return true;
}
} catch (final CoreException e) {
}

return false;
}
}
Loading

0 comments on commit 463a24c

Please sign in to comment.