Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'ikil' of github.com:olabini/ioke into ikil

  • Loading branch information...
commit de14fdd0aea1fac22231016fa6516786b2d08349 2 parents ee9c41c + 6beac48
@olabini authored
View
4 bin/ikil
@@ -0,0 +1,4 @@
+#!/usr/bin/env ioke
+
+use("ikil")
+IKIL generate(*(System programArguments))
View
BIN  bootstrap/ioke.jar
Binary file not shown
View
12 build.xml
@@ -29,7 +29,15 @@
<exec executable="ruby" input="generate_filter_data.rb" failonerror="false" failifexecutionfails="false"/>
</target>
- <target name="compile" depends="generate_filters" description="Compile the source files for the project.">
+ <target name="ikil" depends="prepare" description="Runs IKIL to generate Java source files from the IKIL DSL">
+ <java classname="ioke.lang.Main" fork="true" failonerror="true" maxmemory="256m">
+ <classpath path="bootstrap/ioke.jar"/>
+
+ <arg line="bin/ikil -j src/ikil src/ikj/generated"/>
+ </java>
+ </target>
+
+ <target name="compile" depends="generate_filters, ikil" description="Compile the source files for the project.">
<filter filtersfile="version_data.properties"/>
<filter token="VERSION" value="P"/>
<filter token="VERSION_RUNTIME" value="0.4.1-SNAPSHOT"/>
@@ -38,6 +46,7 @@
<javac destdir="${classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" encoding="UTF-8">
<classpath refid="build.classpath"/>
<src path="${src.dir}"/>
+ <src path="${src.generated.dir}"/>
<include name="**/*.java"/>
</javac>
@@ -183,5 +192,6 @@
<delete dir="${build.dir}"/>
<delete file="${lib.dir}/ioke.jar" quiet="true"/>
<delete file="${lib.dir}/ioke-lib.jar" quiet="true"/>
+ <delete dir="${src.generated.dir}"/>
</target>
</project>
View
1  default.build.properties
@@ -1,5 +1,6 @@
src.raw.dir=src
src.dir=src/ikj/main
+src.generated.dir=src/ikj/generated
lib.dir=lib
lib.build.dir=${lib.dir}/build
lib.release.dir=${lib.dir}/release
View
11 ioke-ikc.build
@@ -7,6 +7,7 @@
<property name="src.raw.dir" value="src"/>
<property name="src.dir" value="src/ikc/main"/>
+ <property name="src.generated.dir" value="src/ikc/generated"/>
<property name="lib.dir" value="lib"/>
<property name="lib.build.dir" value="${lib.dir}/build"/>
<property name="bin.dir" value="bin"/>
@@ -26,7 +27,13 @@
</exec>
</target>
- <target name="compile" depends="generate_filters" description="Compile the source files for the project.">
+ <target name="ikil" depends="prepare" description="Runs IKIL to generate C# source files from the IKIL DSL">
+ <exec program="java">
+ <arg line="-cp bootstrap/ioke.jar ioke.lang.Main bin/ikil -c src/ikil ${src.generated.dir}"/>
+ </exec>
+ </target>
+
+ <target name="compile" depends="generate_filters, ikil" description="Compile the source files for the project.">
<csc target="library" output="${bin.dir}/Ioke.Math.dll" debug="true">
<sources>
<include name="${src.dir}/Ioke.Math/**/*.cs" />
@@ -66,6 +73,7 @@ ioke.build.commit=${version::extract-commit()}
<csc target="library" output="${bin.dir}/Ioke.Lang.dll" debug="true">
<sources>
+ <include name="${src.generated.dir}/Ioke.Lang/**/*.cs" />
<include name="${src.dir}/getline.cs" />
<include name="${src.dir}/Ioke.Lang/**/*.cs" />
<exclude name="${src.dir}/Ioke.Lang/Main.cs"/>
@@ -180,6 +188,7 @@ ioke.build.commit=${version::extract-commit()}
<target name="dist-notest" depends="compile, dist-bin"/>
<target name="clean" description="clean almost everything">
+ <delete dir="${src.generated.dir}"/>
<delete file="${bin.dir}/ioke.dll"/>
<delete file="${bin.dir}/ioke.dll.mdb"/>
<delete file="${bin.dir}/ioke.exe"/>
View
8 lib/ioke/ikil.ik
@@ -0,0 +1,8 @@
+
+IKIL = Origin mimic
+IKIL Language = Origin mimic
+
+use("ikil/dsl")
+use("ikil/main")
+use("ikil/languages/java")
+use("ikil/languages/csharp")
View
11 lib/ioke/ikil/dsl.ik
@@ -0,0 +1,11 @@
+
+IKIL definitions = []
+IKIL cell(:"{}") = macro(
+ call arguments[0] selected(name == :"=") each(msg,
+ def = Origin mimic
+ def className = msg arguments[0] name asText
+ def definitionName = msg arguments[1] name
+ def definition = msg arguments[1] arguments
+ definitions << def
+ )
+)
View
23 lib/ioke/ikil/languages/csharp.ik
@@ -0,0 +1,23 @@
+
+IKIL Language CSharp = IKIL Language mimic
+
+IKIL Language CSharp createFile = method(name, dir, content,
+ fullDir = "#{dir}/Ioke.Lang"
+ FileSystem ensureDirectory(fullDir)
+ FileSystem withOpenFile("#{fullDir}/#{name}.cs", fn(f, f print(content)))
+)
+
+IKIL Language CSharp defineSimpleIokeObject = method(name, parent,
+ "
+namespace Ioke.Lang {
+ public class #{name} {
+ public static void Init(IokeObject obj) {
+ Runtime runtime = obj.runtime;
+ obj.Kind = \"#{name}\";
+ obj.MimicsWithoutCheck((IokeObject)runtime.IokeGround.GetCell(null, null, \"#{parent}\"));
+ runtime.IokeGround.RegisterCell(\"#{name}\", obj);
+ }
+ }
+}
+"
+)
View
25 lib/ioke/ikil/languages/java.ik
@@ -0,0 +1,25 @@
+
+IKIL Language Java = IKIL Language mimic
+
+IKIL Language Java createFile = method(name, dir, content,
+ fullDir = "#{dir}/ioke/lang"
+ FileSystem ensureDirectory(fullDir)
+ FileSystem withOpenFile("#{fullDir}/#{name}.java", fn(f, f print(content)))
+)
+
+IKIL Language Java defineSimpleIokeObject = method(name, parent,
+ "
+package ioke.lang;
+
+import ioke.lang.exceptions.ControlFlow;
+
+public class #{name} {
+ public static void init(IokeObject obj) throws ControlFlow {
+ Runtime runtime = obj.runtime;
+ obj.setKind(\"#{name}\");
+ obj.mimicsWithoutCheck((IokeObject)runtime.iokeGround.getCell(null, null, \"#{parent}\"));
+ runtime.iokeGround.registerCell(\"#{name}\", obj);
+ }
+}
+"
+)
View
17 lib/ioke/ikil/main.ik
@@ -0,0 +1,17 @@
+
+IKIL generate = method(language, directory, outDirectory,
+ FileSystem["#{directory}/**/*.ik"] each(name,
+ use(name)
+ )
+
+ lang = case(language,
+ or("-java", "-j"), Language Java,
+ or("-csharp", "-c"), Language CSharp)
+
+ definitions each(def,
+ case(def definitionName,
+ :IokeObject, lang createFile(def className, outDirectory, lang defineSimpleIokeObject(def className, *(def definition))),
+ else, "can't handle #{def definitionName}" println
+ )
+ )
+)
View
2  src/ikc/main/Ioke.Lang/Ground.cs
@@ -41,8 +41,6 @@ public class Ground {
iokeGround.RegisterCell("Message", runtime.Message);
iokeGround.RegisterCell("Call", runtime.Call);
iokeGround.RegisterCell("Condition", runtime.Condition);
- iokeGround.RegisterCell("Rescue", runtime.Rescue);
- iokeGround.RegisterCell("Handler", runtime.Handler);
iokeGround.RegisterCell("IO", runtime.Io);
iokeGround.RegisterCell("FileSystem", runtime.FileSystem);
iokeGround.RegisterCell("Regexp", runtime.Regexp);
View
7 src/ikc/main/Ioke.Lang/Handler.cs
@@ -1,7 +0,0 @@
-namespace Ioke.Lang {
- public class Handler {
- public static void Init(IokeObject obj) {
- obj.Kind = "Handler";
- }
- }
-}
View
7 src/ikc/main/Ioke.Lang/Rescue.cs
@@ -1,7 +0,0 @@
-namespace Ioke.Lang {
- public class Rescue {
- public static void Init(IokeObject obj) {
- obj.Kind = "Rescue";
- }
- }
-}
View
2  src/ikc/main/Ioke.Lang/Runtime.cs
@@ -331,8 +331,6 @@ public class Runtime : IokeData {
this.Set.MimicsWithoutCheck(Origin);
Condition.MimicsWithoutCheck(Origin);
- Rescue.MimicsWithoutCheck(Origin);
- Handler.MimicsWithoutCheck(Origin);
Io.MimicsWithoutCheck(Origin);
View
5 src/ikil/conditions.ik
@@ -0,0 +1,5 @@
+
+IKIL {
+ Handler = IokeObject(Origin)
+ Rescue = IokeObject(Origin)
+}
View
55 src/ikil/range.ik
@@ -0,0 +1,55 @@
+
+IKIL {
+ ;; will create fields and constructor automatically
+ ;; will create an init method that makes sure it inits the correct things
+ ;; will add accessors for all the fields
+ ;; will add native method stuff for all methods defined
+ ;; will add standardized getInspect and getNotice
+
+ Range = IokeObjectData([Origin, Mixins Sequenced],
+ from = IokeObject
+ to = IokeObject
+ inclusive = boolean
+ inverted = boolean
+
+ methods {
+ exclusive?: method("returns true if the receiver is an exclusive range, false otherwise",
+ return(boolean(not(data inclusive)))),
+
+ inclusive?: method("returns true if the receiver is an inclusive range, false otherwise",
+ return(boolean(data inclusive))),
+
+ from: method("returns the 'from' part of the range",
+ return(data from)),
+
+ to: method("returns the 'to' part of the range",
+ return(data to)),
+
+ inspect: method("Returns a text inspection of the object",
+ return(text(inspect(self)))),
+
+ notice: method("Returns a brief text inspection of the object",
+ return(text(notice(self)))),
+ }
+
+ inspect {
+ append(globalInspect(from))
+
+ if(inclusive,
+ append(".."),
+ append("..."))
+
+ append(globalInspect(to))
+ }
+
+ notice {
+ append(globalNotice(from))
+
+ if(inclusive,
+ append(".."),
+ append("..."))
+
+ append(globalNotice(to))
+ }
+ )
+}
View
2  src/ikj/main/ioke/lang/Ground.java
@@ -51,8 +51,6 @@ public static void init(IokeObject iokeGround, IokeObject ground) throws Control
iokeGround.registerCell("Message", runtime.message);
iokeGround.registerCell("Call", runtime.call);
iokeGround.registerCell("Condition", runtime.condition);
- iokeGround.registerCell("Rescue", runtime.rescue);
- iokeGround.registerCell("Handler", runtime.handler);
iokeGround.registerCell("IO", runtime.io);
iokeGround.registerCell("FileSystem", runtime.fileSystem);
iokeGround.registerCell("Regexp", runtime.regexp);
View
17 src/ikj/main/ioke/lang/Handler.java
@@ -1,17 +0,0 @@
-/*
- * See LICENSE file in distribution for copyright and licensing information.
- */
-package ioke.lang;
-
-import ioke.lang.exceptions.ControlFlow;
-
-/**
- *
- * @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
- */
-public class Handler {
- public static void init(IokeObject obj) throws ControlFlow {
- Runtime runtime = obj.runtime;
- obj.setKind("Handler");
- }
-}// Handler
View
17 src/ikj/main/ioke/lang/Rescue.java
@@ -1,17 +0,0 @@
-/*
- * See LICENSE file in distribution for copyright and licensing information.
- */
-package ioke.lang;
-
-import ioke.lang.exceptions.ControlFlow;
-
-/**
- *
- * @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
- */
-public class Rescue {
- public static void init(IokeObject obj) throws ControlFlow {
- Runtime runtime = obj.runtime;
- obj.setKind("Rescue");
- }
-}// Rescue
View
2  src/ikj/main/ioke/lang/Runtime.java
@@ -285,8 +285,6 @@ public void init() throws ControlFlow {
set.mimicsWithoutCheck(origin);
condition.mimicsWithoutCheck(origin);
- rescue.mimicsWithoutCheck(origin);
- handler.mimicsWithoutCheck(origin);
io.mimicsWithoutCheck(origin);
Please sign in to comment.
Something went wrong with that request. Please try again.