Skip to content

Commit

Permalink
Merge branch 'ikil' of github.com:olabini/ioke into ikil
Browse files Browse the repository at this point in the history
  • Loading branch information
olabini committed Feb 18, 2010
2 parents ee9c41c + 6beac48 commit de14fdd
Show file tree
Hide file tree
Showing 20 changed files with 170 additions and 58 deletions.
4 changes: 4 additions & 0 deletions bin/ikil
@@ -0,0 +1,4 @@
#!/usr/bin/env ioke

use("ikil")
IKIL generate(*(System programArguments))
Binary file added bootstrap/ioke.jar
Binary file not shown.
12 changes: 11 additions & 1 deletion build.xml
Expand Up @@ -29,7 +29,15 @@
<exec executable="ruby" input="generate_filter_data.rb" failonerror="false" failifexecutionfails="false"/> <exec executable="ruby" input="generate_filter_data.rb" failonerror="false" failifexecutionfails="false"/>
</target> </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 filtersfile="version_data.properties"/>
<filter token="VERSION" value="P"/> <filter token="VERSION" value="P"/>
<filter token="VERSION_RUNTIME" value="0.4.1-SNAPSHOT"/> <filter token="VERSION_RUNTIME" value="0.4.1-SNAPSHOT"/>
Expand All @@ -38,6 +46,7 @@
<javac destdir="${classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" encoding="UTF-8"> <javac destdir="${classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" encoding="UTF-8">
<classpath refid="build.classpath"/> <classpath refid="build.classpath"/>
<src path="${src.dir}"/> <src path="${src.dir}"/>
<src path="${src.generated.dir}"/>
<include name="**/*.java"/> <include name="**/*.java"/>
</javac> </javac>


Expand Down Expand Up @@ -183,5 +192,6 @@
<delete dir="${build.dir}"/> <delete dir="${build.dir}"/>
<delete file="${lib.dir}/ioke.jar" quiet="true"/> <delete file="${lib.dir}/ioke.jar" quiet="true"/>
<delete file="${lib.dir}/ioke-lib.jar" quiet="true"/> <delete file="${lib.dir}/ioke-lib.jar" quiet="true"/>
<delete dir="${src.generated.dir}"/>
</target> </target>
</project> </project>
1 change: 1 addition & 0 deletions default.build.properties
@@ -1,5 +1,6 @@
src.raw.dir=src src.raw.dir=src
src.dir=src/ikj/main src.dir=src/ikj/main
src.generated.dir=src/ikj/generated
lib.dir=lib lib.dir=lib
lib.build.dir=${lib.dir}/build lib.build.dir=${lib.dir}/build
lib.release.dir=${lib.dir}/release lib.release.dir=${lib.dir}/release
Expand Down
11 changes: 10 additions & 1 deletion ioke-ikc.build
Expand Up @@ -7,6 +7,7 @@


<property name="src.raw.dir" value="src"/> <property name="src.raw.dir" value="src"/>
<property name="src.dir" value="src/ikc/main"/> <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.dir" value="lib"/>
<property name="lib.build.dir" value="${lib.dir}/build"/> <property name="lib.build.dir" value="${lib.dir}/build"/>
<property name="bin.dir" value="bin"/> <property name="bin.dir" value="bin"/>
Expand All @@ -26,7 +27,13 @@
</exec> </exec>
</target> </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"> <csc target="library" output="${bin.dir}/Ioke.Math.dll" debug="true">
<sources> <sources>
<include name="${src.dir}/Ioke.Math/**/*.cs" /> <include name="${src.dir}/Ioke.Math/**/*.cs" />
Expand Down Expand Up @@ -66,6 +73,7 @@ ioke.build.commit=${version::extract-commit()}


<csc target="library" output="${bin.dir}/Ioke.Lang.dll" debug="true"> <csc target="library" output="${bin.dir}/Ioke.Lang.dll" debug="true">
<sources> <sources>
<include name="${src.generated.dir}/Ioke.Lang/**/*.cs" />
<include name="${src.dir}/getline.cs" /> <include name="${src.dir}/getline.cs" />
<include name="${src.dir}/Ioke.Lang/**/*.cs" /> <include name="${src.dir}/Ioke.Lang/**/*.cs" />
<exclude name="${src.dir}/Ioke.Lang/Main.cs"/> <exclude name="${src.dir}/Ioke.Lang/Main.cs"/>
Expand Down Expand Up @@ -180,6 +188,7 @@ ioke.build.commit=${version::extract-commit()}
<target name="dist-notest" depends="compile, dist-bin"/> <target name="dist-notest" depends="compile, dist-bin"/>


<target name="clean" description="clean almost everything"> <target name="clean" description="clean almost everything">
<delete dir="${src.generated.dir}"/>
<delete file="${bin.dir}/ioke.dll"/> <delete file="${bin.dir}/ioke.dll"/>
<delete file="${bin.dir}/ioke.dll.mdb"/> <delete file="${bin.dir}/ioke.dll.mdb"/>
<delete file="${bin.dir}/ioke.exe"/> <delete file="${bin.dir}/ioke.exe"/>
Expand Down
8 changes: 8 additions & 0 deletions 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")
11 changes: 11 additions & 0 deletions 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
)
)
23 changes: 23 additions & 0 deletions 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);
}
}
}
"
)
25 changes: 25 additions & 0 deletions 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);
}
}
"
)
17 changes: 17 additions & 0 deletions 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
)
)
)
2 changes: 0 additions & 2 deletions src/ikc/main/Ioke.Lang/Ground.cs
Expand Up @@ -41,8 +41,6 @@ public class Ground {
iokeGround.RegisterCell("Message", runtime.Message); iokeGround.RegisterCell("Message", runtime.Message);
iokeGround.RegisterCell("Call", runtime.Call); iokeGround.RegisterCell("Call", runtime.Call);
iokeGround.RegisterCell("Condition", runtime.Condition); iokeGround.RegisterCell("Condition", runtime.Condition);
iokeGround.RegisterCell("Rescue", runtime.Rescue);
iokeGround.RegisterCell("Handler", runtime.Handler);
iokeGround.RegisterCell("IO", runtime.Io); iokeGround.RegisterCell("IO", runtime.Io);
iokeGround.RegisterCell("FileSystem", runtime.FileSystem); iokeGround.RegisterCell("FileSystem", runtime.FileSystem);
iokeGround.RegisterCell("Regexp", runtime.Regexp); iokeGround.RegisterCell("Regexp", runtime.Regexp);
Expand Down
7 changes: 0 additions & 7 deletions src/ikc/main/Ioke.Lang/Handler.cs

This file was deleted.

7 changes: 0 additions & 7 deletions src/ikc/main/Ioke.Lang/Rescue.cs

This file was deleted.

2 changes: 0 additions & 2 deletions src/ikc/main/Ioke.Lang/Runtime.cs
Expand Up @@ -331,8 +331,6 @@ public class Runtime : IokeData {
this.Set.MimicsWithoutCheck(Origin); this.Set.MimicsWithoutCheck(Origin);


Condition.MimicsWithoutCheck(Origin); Condition.MimicsWithoutCheck(Origin);
Rescue.MimicsWithoutCheck(Origin);
Handler.MimicsWithoutCheck(Origin);


Io.MimicsWithoutCheck(Origin); Io.MimicsWithoutCheck(Origin);


Expand Down
5 changes: 5 additions & 0 deletions src/ikil/conditions.ik
@@ -0,0 +1,5 @@

IKIL {
Handler = IokeObject(Origin)
Rescue = IokeObject(Origin)
}
55 changes: 55 additions & 0 deletions 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))
}
)
}
2 changes: 0 additions & 2 deletions src/ikj/main/ioke/lang/Ground.java
Expand Up @@ -51,8 +51,6 @@ public static void init(IokeObject iokeGround, IokeObject ground) throws Control
iokeGround.registerCell("Message", runtime.message); iokeGround.registerCell("Message", runtime.message);
iokeGround.registerCell("Call", runtime.call); iokeGround.registerCell("Call", runtime.call);
iokeGround.registerCell("Condition", runtime.condition); iokeGround.registerCell("Condition", runtime.condition);
iokeGround.registerCell("Rescue", runtime.rescue);
iokeGround.registerCell("Handler", runtime.handler);
iokeGround.registerCell("IO", runtime.io); iokeGround.registerCell("IO", runtime.io);
iokeGround.registerCell("FileSystem", runtime.fileSystem); iokeGround.registerCell("FileSystem", runtime.fileSystem);
iokeGround.registerCell("Regexp", runtime.regexp); iokeGround.registerCell("Regexp", runtime.regexp);
Expand Down
17 changes: 0 additions & 17 deletions src/ikj/main/ioke/lang/Handler.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/ikj/main/ioke/lang/Rescue.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/ikj/main/ioke/lang/Runtime.java
Expand Up @@ -285,8 +285,6 @@ public void init() throws ControlFlow {
set.mimicsWithoutCheck(origin); set.mimicsWithoutCheck(origin);


condition.mimicsWithoutCheck(origin); condition.mimicsWithoutCheck(origin);
rescue.mimicsWithoutCheck(origin);
handler.mimicsWithoutCheck(origin);


io.mimicsWithoutCheck(origin); io.mimicsWithoutCheck(origin);


Expand Down

0 comments on commit de14fdd

Please sign in to comment.