basic language support for sublime and vscode
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
fun dummy() {}
|
||||
Func = type(dummy);
|
||||
NFunc = type(print); # The function type is not a build-in at the moment,
|
||||
NFunc = type(print); # The function type is not a built-in at the moment,
|
||||
# but we can define it manually.
|
||||
|
||||
fun copyList(list: List) {
|
||||
|
||||
@@ -8,7 +8,7 @@ fun newCircularQueue(T: Type = int, max: int = 3) {
|
||||
|
||||
if max <= 0:
|
||||
error("Maximum queue size must be positive");
|
||||
|
||||
|
||||
list = [];
|
||||
i = 0;
|
||||
while i < max: {
|
||||
|
||||
+13
-11
@@ -11,14 +11,16 @@ fun isDigit(c: String) {
|
||||
and d <= 9;
|
||||
}
|
||||
|
||||
fun skipSpaces(context: Map) {
|
||||
ParsingContext = {str: String, cur: int};
|
||||
|
||||
fun skipSpaces(context: ParsingContext) {
|
||||
# Skip zero or more whitespace characters.
|
||||
while context.cur < count(context.str)
|
||||
and isSpace(context.str[context.cur]):
|
||||
context.cur = context.cur + 1;
|
||||
}
|
||||
|
||||
fun parseNull(context: Map) {
|
||||
fun parseNull(context: ParsingContext) {
|
||||
|
||||
assert(context.cur < count(context.str)
|
||||
and context.str[context.cur] == 'n');
|
||||
@@ -33,7 +35,7 @@ fun parseNull(context: Map) {
|
||||
return none;
|
||||
}
|
||||
|
||||
fun parseTrue(context: Map) {
|
||||
fun parseTrue(context: ParsingContext) {
|
||||
|
||||
assert(context.cur < count(context.str)
|
||||
and context.str[context.cur] == 't');
|
||||
@@ -48,7 +50,7 @@ fun parseTrue(context: Map) {
|
||||
return true;
|
||||
}
|
||||
|
||||
fun parseFalse(context: Map) {
|
||||
fun parseFalse(context: ParsingContext) {
|
||||
|
||||
assert(context.cur < count(context.str)
|
||||
and context.str[context.cur] == 'f');
|
||||
@@ -67,7 +69,7 @@ fun parseFalse(context: Map) {
|
||||
fun dummy() {}
|
||||
Func = type(dummy);
|
||||
|
||||
fun skip(context: Map, test_callback: Func) {
|
||||
fun skip(context: ParsingContext, test_callback: Func) {
|
||||
k = context.cur;
|
||||
while k < count(context.str)
|
||||
and test_callback(context.str[k]):
|
||||
@@ -75,7 +77,7 @@ fun skip(context: Map, test_callback: Func) {
|
||||
return k;
|
||||
}
|
||||
|
||||
fun parseInteger(context: Map) {
|
||||
fun parseInteger(context: ParsingContext) {
|
||||
assert(context.cur < count(context.str) and isDigit(context.str[context.cur]));
|
||||
|
||||
buffer = 0;
|
||||
@@ -91,7 +93,7 @@ fun parseInteger(context: Map) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
fun parseFloating(context: Map) {
|
||||
fun parseFloating(context: ParsingContext) {
|
||||
assert(context.cur < count(context.str)
|
||||
and isDigit(context.str[context.cur]));
|
||||
|
||||
@@ -125,7 +127,7 @@ fun parseFloating(context: Map) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
fun parseIntegerOrFloating(context: Map) {
|
||||
fun parseIntegerOrFloating(context: ParsingContext) {
|
||||
assert(context.cur < count(context.str)
|
||||
and isDigit(context.str[context.cur]));
|
||||
|
||||
@@ -141,7 +143,7 @@ fun parseIntegerOrFloating(context: Map) {
|
||||
return parseInteger(context);
|
||||
}
|
||||
|
||||
fun parseString(context: Map) {
|
||||
fun parseString(context: ParsingContext) {
|
||||
|
||||
assert(context.cur < count(context.str)
|
||||
and context.str[context.cur] == '"');
|
||||
@@ -164,7 +166,7 @@ fun parseString(context: Map) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
fun parseArray(context: Map) {
|
||||
fun parseArray(context: ParsingContext) {
|
||||
assert(context.cur < count(context.str)
|
||||
and context.str[context.cur] == '[');
|
||||
|
||||
@@ -210,7 +212,7 @@ fun parseArray(context: Map) {
|
||||
return list;
|
||||
}
|
||||
|
||||
fun parseValue(context: Map) {
|
||||
fun parseValue(context: ParsingContext) {
|
||||
|
||||
if context.cur == count(context.str):
|
||||
return none, "Source ended where a value was expected";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This script reads the contents of the specified
|
||||
# folder, and then prints all of the containd files.
|
||||
|
||||
|
||||
dirname = '.';
|
||||
dir = files.openDir(dirname);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user