Move ReaderExp to its own file
This commit is contained in:
@@ -6,6 +6,7 @@ import haxe.macro.PositionTools;
|
||||
import hscript.Parser;
|
||||
import hscript.Interp;
|
||||
import kiss.Reader;
|
||||
import kiss.ReaderExp;
|
||||
import kiss.CompileError;
|
||||
import kiss.Kiss;
|
||||
import kiss.SpecialForms;
|
||||
@@ -246,7 +247,7 @@ class Helpers {
|
||||
interp.variables.set("ReaderExp", ReaderExpDef);
|
||||
interp.variables.set("nextToken", Reader.nextToken.bind(_, "a token"));
|
||||
interp.variables.set("kiss", {
|
||||
Reader: {
|
||||
ReaderExp: {
|
||||
ReaderExpDef: ReaderExpDef
|
||||
},
|
||||
Operand: {
|
||||
|
@@ -7,6 +7,7 @@ import haxe.macro.Expr;
|
||||
import haxe.io.Path;
|
||||
import kiss.Stream;
|
||||
import kiss.Reader;
|
||||
import kiss.ReaderExp;
|
||||
import kiss.FieldForms;
|
||||
import kiss.SpecialForms;
|
||||
import kiss.Macros;
|
||||
|
@@ -3,6 +3,7 @@ package kiss;
|
||||
import haxe.macro.Expr;
|
||||
import haxe.macro.Context;
|
||||
import kiss.Reader;
|
||||
import kiss.ReaderExp;
|
||||
import kiss.Kiss;
|
||||
import kiss.CompileError;
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package kiss;
|
||||
using Std;
|
||||
|
||||
import kiss.Operand;
|
||||
import kiss.ReaderExp;
|
||||
import haxe.ds.Either;
|
||||
import haxe.Constraints;
|
||||
#if (!macro && hxnodejs)
|
||||
|
@@ -3,16 +3,12 @@ package kiss;
|
||||
import haxe.ds.Option;
|
||||
import kiss.Stream;
|
||||
import kiss.Kiss;
|
||||
import kiss.ReaderExp;
|
||||
|
||||
using kiss.Reader;
|
||||
using kiss.Stream;
|
||||
using kiss.Helpers;
|
||||
|
||||
typedef ReaderExp = {
|
||||
pos:Position,
|
||||
def:ReaderExpDef
|
||||
};
|
||||
|
||||
class UnmatchedBracketSignal {
|
||||
public var type:String;
|
||||
public var position:Stream.Position;
|
||||
@@ -23,21 +19,6 @@ class UnmatchedBracketSignal {
|
||||
}
|
||||
}
|
||||
|
||||
enum ReaderExpDef {
|
||||
CallExp(func:ReaderExp, args:Array<ReaderExp>); // (f a1 a2...)
|
||||
ListExp(exps:Array<ReaderExp>); // [v1 v2 v3]
|
||||
StrExp(s:String); // "literal"
|
||||
Symbol(name:String); // s
|
||||
RawHaxe(code:String); // #| haxeCode() |#
|
||||
TypedExp(path:String, exp:ReaderExp); // :type [exp]
|
||||
MetaExp(meta:String, exp:ReaderExp); // &meta [exp]
|
||||
FieldExp(field:String, exp:ReaderExp); // .field [exp]
|
||||
KeyValueExp(key:ReaderExp, value:ReaderExp); // =>key value
|
||||
Quasiquote(exp:ReaderExp); // `[exp]
|
||||
Unquote(exp:ReaderExp); // ,[exp]
|
||||
UnquoteList(exp:ReaderExp); // ,@[exp]
|
||||
}
|
||||
|
||||
typedef ReadFunction = (Stream, KissState) -> Null<ReaderExpDef>;
|
||||
typedef ReadTable = Map<String, ReadFunction>;
|
||||
|
||||
|
23
kiss/src/kiss/ReaderExp.hx
Normal file
23
kiss/src/kiss/ReaderExp.hx
Normal file
@@ -0,0 +1,23 @@
|
||||
package kiss;
|
||||
|
||||
import kiss.Stream;
|
||||
|
||||
typedef ReaderExp = {
|
||||
pos:Position,
|
||||
def:ReaderExpDef
|
||||
};
|
||||
|
||||
enum ReaderExpDef {
|
||||
CallExp(func:ReaderExp, args:Array<ReaderExp>); // (f a1 a2...)
|
||||
ListExp(exps:Array<ReaderExp>); // [v1 v2 v3]
|
||||
StrExp(s:String); // "literal"
|
||||
Symbol(name:String); // s
|
||||
RawHaxe(code:String); // #| haxeCode() |#
|
||||
TypedExp(path:String, exp:ReaderExp); // :type [exp]
|
||||
MetaExp(meta:String, exp:ReaderExp); // &meta [exp]
|
||||
FieldExp(field:String, exp:ReaderExp); // .field [exp]
|
||||
KeyValueExp(key:ReaderExp, value:ReaderExp); // =>key value
|
||||
Quasiquote(exp:ReaderExp); // `[exp]
|
||||
Unquote(exp:ReaderExp); // ,[exp]
|
||||
UnquoteList(exp:ReaderExp); // ,@[exp]
|
||||
}
|
@@ -3,6 +3,7 @@ package kiss;
|
||||
import haxe.macro.Expr;
|
||||
import haxe.macro.Context;
|
||||
import kiss.Reader;
|
||||
import kiss.ReaderExp;
|
||||
import uuid.Uuid;
|
||||
import kiss.Kiss;
|
||||
|
||||
|
9
projects/nap/src/test/TestMain.hx
Normal file
9
projects/nap/src/test/TestMain.hx
Normal file
@@ -0,0 +1,9 @@
|
||||
package test;
|
||||
|
||||
import kiss.Kiss;
|
||||
import kiss.Prelude;
|
||||
import nap.BoolExpInterp;
|
||||
import nap.Archive;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class TestMain {}
|
25
projects/nap/src/test/TestMain.kiss
Normal file
25
projects/nap/src/test/TestMain.kiss
Normal file
@@ -0,0 +1,25 @@
|
||||
(defun :Void main []
|
||||
(assert (BoolExpInterp.eval "true" []))
|
||||
(assert !(BoolExpInterp.eval "false" []))
|
||||
(assert !(BoolExpInterp.eval "flag" []))
|
||||
(assert (BoolExpInterp.eval "flag" ["flag"]))
|
||||
(assert !(BoolExpInterp.eval "(and flag false)" ["flag"]))
|
||||
(assert (BoolExpInterp.eval "(or flag otherFlag)" ["otherFlag"]))
|
||||
//trace(error);
|
||||
(let [systems
|
||||
[]
|
||||
archive
|
||||
(new Archive "src/test/example-archive" systems)]
|
||||
(print "TODO")))
|
||||
|
||||
|
||||
|
||||
/*
|
||||
(let [e (new Entry "name")]
|
||||
(dictSet e.components "f" [5])
|
||||
(dictSet e.components "b" [(object c "d")])
|
||||
(let [s (haxe.Json.stringify e)
|
||||
:Entry e2 (haxe.Json.parse s)]
|
||||
// can't call Entry methods on e2
|
||||
(print s))))
|
||||
*/
|
@@ -0,0 +1 @@
|
||||
"Rafael Krux"
|
@@ -0,0 +1 @@
|
||||
"Kevin MacLeod"
|
@@ -0,0 +1 @@
|
||||
"Adventure"
|
@@ -0,0 +1 @@
|
||||
"Ancient Rite"
|
@@ -0,0 +1,4 @@
|
||||
[
|
||||
["song", 1],
|
||||
["western", 1]
|
||||
]
|
@@ -0,0 +1,4 @@
|
||||
[
|
||||
["song", 1],
|
||||
["religious", 1]
|
||||
]
|
11
projects/nap/src/test/example-archive/entries/song1.json
Normal file
11
projects/nap/src/test/example-archive/entries/song1.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "song1",
|
||||
"components": [
|
||||
["Name", "name1"],
|
||||
["Author", "author1"],
|
||||
["Tags", "tags1"]
|
||||
],
|
||||
"files": [
|
||||
"Adventure.mp3"
|
||||
]
|
||||
}
|
11
projects/nap/src/test/example-archive/entries/song2.json
Normal file
11
projects/nap/src/test/example-archive/entries/song2.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "song2",
|
||||
"components": [
|
||||
["Name", "name2"],
|
||||
["Author", "author2"],
|
||||
["Tags", "tags2"]
|
||||
],
|
||||
"files": [
|
||||
"Ancient Rite.mp3"
|
||||
]
|
||||
}
|
BIN
projects/nap/src/test/example-archive/files/Adventure.mp3
Normal file
BIN
projects/nap/src/test/example-archive/files/Adventure.mp3
Normal file
Binary file not shown.
BIN
projects/nap/src/test/example-archive/files/Ancient Rite.mp3
Normal file
BIN
projects/nap/src/test/example-archive/files/Ancient Rite.mp3
Normal file
Binary file not shown.
Reference in New Issue
Block a user