Skip to content

Instantly share code, notes, and snippets.

View samaaron's full-sized avatar

Sam Aaron samaaron

View GitHub Profile
Buildfile: build.xml
prepare:
[mkdir] Created dir: /Users/sam/Development/melwin/build
[mkdir] Created dir: /Users/sam/Development/melwin/build/coverage
[mkdir] Created dir: /Users/sam/Development/melwin/build/classes
[mkdir] Created dir: /Users/sam/Development/melwin/src/generated/ioke/lang/parser
generate.antlr:
[java] ANTLR Parser Generator Version 3.1.1
obj.registerMethod(runtime.newJavaMethod("will remove all the entries from the list, and then returns the list", new JavaMethod.WithNoArguments("clear!") {
@Override
public Object activate(IokeObject method, IokeObject context, IokeObject message, Object on) throws ControlFlow {
getArguments().getEvaluatedArguments(context, message, on, new ArrayList<Object>(), new HashMap<String, Object>());
Object onAsList = IokeList.convertTo(on, true, message, context);
IokeList.getList(onAsList).clear();
return onAsList;
}
DefaultBehavior Definitions dmacro = syntax(
"takes one optional documentation string, and one or more
arguments. these argument should all begin with a literal array.
This literal array will be interpreted as a destructuring
pattern. the syntax macro will expand into a macro that will read
dispatch based on all the patterns given. the first pattern
that matches will be used. the code coming after the literal
array will have access to the variables defined in the pattern.
the result of this code will be the result of the macro.
public static List<Object> getList(Object on, IokeObject message, IokeObject context) {
Object onAsList = IokeList.convertTo(on, true, message, context);
return onAsList.getList();
}
public static List<Object> getList(Object on) {
return ((IokeList)(IokeObject.data(on))).getList();
}
public static List<Object> getList(Object on, IokeObject message, IokeObject context) {
Object onAsList = IokeList.convertTo(on, true, message, context);
return onAsList.getList();
}
obj.registerMethod(obj.runtime.newJavaMethod("Returns a text inspection of the object", new TypeCheckingJavaMethod.WithNoArguments("inspect", runtime.list) {
@Override
public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
return method.runtime.newText(IokeList.getInspect(on));
}
}));
obj.registerMethod(runtime.newJavaMethod("takes either one or two or three arguments. if one argument is given, it should be a message chain that will be sent to each object in the list. the result will be thrown away. if two arguments are given, the first is an unevaluated name that will be set to each of the values in the list in succession, and then the second argument will be evaluated in a scope with that argument in it. if three arguments is given, the first one is an unevaluated name that will be set to the index of each element, and the other two arguments are the name of the argument for the value, and the actual code. the code will evaluate in a lexical context, and if the argument name is available outside the context, it will be shadowed. the method will return the list.", new TypeCheckingJavaMethod("each") {
private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
.builder()
.receiverMustMimic(
[java] DefaultBehavior asText
[java] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[java] at org.jregex.Block.add(Bitset.java:359)
[java] at org.jregex.Bitset.setCategory(Bitset.java:148)
[java] at org.jregex.Bitset.setWordChar(Bitset.java:109)
[java] at org.jregex.CharacterClass.<clinit>(CharacterClass.java:100)
[java] at org.jregex.Term.parseTerm(Term.java:1040)
[java] at org.jregex.Term.append(Term.java:477)
[java] at org.jregex.Term.makeTree(Term.java:214)
[java] at org.jregex.Term.makeTree(Term.java:174)
obj.registerMethod(runtime.newJavaMethod("takes either one or two or three arguments. if one argument is given, it should be a message chain that will be sent to each object in the list. the result will be thrown away. if two arguments are given, the first is an unevaluated name that will be set to each of the values in the list in succession, and then the second argument will be evaluated in a scope with that argument in it. if three arguments is given, the first one is an unevaluated name that will be set to the index of each element, and the other two arguments are the name of the argument for the value, and the actual code. the code will evaluate in a lexical context, and if the argument name is available outside the context, it will be shadowed. the method will return the list.", new JavaMethod("each") {
private final DefaultArgumentsDefinition ARGUMENTS = DefaultArgumentsDefinition
.builder()
.withRequiredPositionalUnevaluated("indexOrArgOrCode"
obj.registerMethod(obj.runtime.newJavaMethod("Returns a text inspection of the object", new TypeCheckingJavaMethod.WithNoArguments("inspect", obj.runtime.symbol) {
@Override
public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
return method.runtime.newText(Symbol.getInspect(on));
}
}));