Bugfixes, range(start,end,step), and beginning work on lexer and symbol
This commit is contained in:
@@ -2,7 +2,7 @@ import io:*
|
||||
import vector:*
|
||||
|
||||
fun onlyMatch(vec: vector<int>, matchWith: int): vector<int> {
|
||||
return vec.filter(fun(it:int, other:int):bool { return it == other; }, matchWith)
|
||||
return vec.filter(fun(it:int):bool { return it == matchWith; })
|
||||
}
|
||||
|
||||
fun main():int {
|
||||
|
||||
2
tests/test_lexer.expected_results
Normal file
2
tests/test_lexer.expected_results
Normal file
@@ -0,0 +1,2 @@
|
||||
a+: aaaa true
|
||||
test: test true
|
||||
16
tests/test_lexer.krak
Normal file
16
tests/test_lexer.krak
Normal file
@@ -0,0 +1,16 @@
|
||||
import lexer:*
|
||||
import regex:*
|
||||
import string:*
|
||||
import symbol:*
|
||||
import io:*
|
||||
|
||||
fun main(): int {
|
||||
var lex.construct(): lexer
|
||||
lex.set_input(string("aaaatesta"))
|
||||
lex.add_regex(regex("a+"))
|
||||
lex.add_regex(regex("test"))
|
||||
println(lex.next().to_string())
|
||||
println(lex.next().to_string())
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -7,3 +7,5 @@ hope3
|
||||
new way!
|
||||
a
|
||||
now win!
|
||||
true
|
||||
false
|
||||
|
||||
@@ -20,6 +20,8 @@ fun main(): int {
|
||||
newWay[5] = 'i'
|
||||
newWay[6] = 'n'
|
||||
io::println(newWay)
|
||||
io::println( string::string("yes") == string::string("yes") )
|
||||
io::println( string::string("no") == string::string("yes") )
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
7.000000
|
||||
2
|
||||
8.000000
|
||||
36912
|
||||
234567
|
||||
false
|
||||
true
|
||||
3
|
||||
hi
|
||||
construct
|
||||
|
||||
@@ -31,6 +31,13 @@ fun main():int {
|
||||
println(greater(1,2))
|
||||
println(greater(7.0,8.0))
|
||||
|
||||
range(3,13, 3).for_each(fun(i: int) { print(i); })
|
||||
println()
|
||||
range(2,8).for_each(fun(i: int) { print(i); })
|
||||
println()
|
||||
println(range(2,8,2).any_true(fun(i: int): bool { return i%2 == 1; } ))
|
||||
println(range(3).any_true(fun(i: int): bool { return i%2 == 1; } ))
|
||||
|
||||
var oddPair = make_pair(3, "hi")
|
||||
println(oddPair.first)
|
||||
println(oddPair.second)
|
||||
|
||||
@@ -71,9 +71,9 @@ Copied: 305 to 306
|
||||
Copied: 306 to 307
|
||||
Destroyed: 306
|
||||
Destroyed: 305
|
||||
Destroyed: 104
|
||||
Destroyed: 204
|
||||
Destroyed: 304
|
||||
Destroyed: 104
|
||||
Destroyed: 301
|
||||
Destroyed: 201
|
||||
Destroyed: 101
|
||||
@@ -92,15 +92,15 @@ Copied: 308 to 309
|
||||
Copied: 309 to 310
|
||||
Destroyed: 309
|
||||
Destroyed: 308
|
||||
Destroyed: 107
|
||||
Destroyed: 207
|
||||
Destroyed: 307
|
||||
Destroyed: 107
|
||||
Destroyed: 210
|
||||
Copied: 310 to 311
|
||||
Destroyed: 310
|
||||
done
|
||||
Destroyed: 311
|
||||
Destroyed: 110
|
||||
Destroyed: 311
|
||||
Destroyed: 300
|
||||
Destroyed: 200
|
||||
Destroyed: 100
|
||||
|
||||
@@ -52,7 +52,7 @@ fun main(): int {
|
||||
for (var i: int = 0; i < intVec.size; i++;)
|
||||
print(intVec.at(i));
|
||||
println();
|
||||
intVec.do(fun(it:int):void print(it+7);)
|
||||
intVec.for_each(fun(it:int):void print(it+7);)
|
||||
println();
|
||||
|
||||
var subd = intVec.map(fun(it:int):int { return it-1; })
|
||||
@@ -90,19 +90,19 @@ fun main(): int {
|
||||
sliceTest.add(3)
|
||||
sliceTest.add(4)
|
||||
print("full: ")
|
||||
sliceTest.do(fun(it:int):void print(it);)
|
||||
sliceTest.for_each(fun(it:int):void print(it);)
|
||||
println()
|
||||
print("middle: ")
|
||||
sliceTest.slice(1,-2).do(fun(it:int):void print(it);)
|
||||
sliceTest.slice(1,-2).for_each(fun(it:int):void print(it);)
|
||||
println()
|
||||
print("all but first: ")
|
||||
sliceTest.slice(1,-1).do(fun(it:int):void print(it);)
|
||||
sliceTest.slice(1,-1).for_each(fun(it:int):void print(it);)
|
||||
println()
|
||||
print("all but last: ")
|
||||
sliceTest.slice(0,-2).do(fun(it:int):void print(it);)
|
||||
sliceTest.slice(0,-2).for_each(fun(it:int):void print(it);)
|
||||
println()
|
||||
print("just some: ")
|
||||
sliceTest.slice(1,2).do(fun(it:int):void print(it);)
|
||||
sliceTest.slice(1,2).for_each(fun(it:int):void print(it);)
|
||||
println()
|
||||
|
||||
println("find test")
|
||||
@@ -116,10 +116,10 @@ fun main(): int {
|
||||
setTest.add(7)
|
||||
setTest.set(1,8)
|
||||
setTest[2] = 9
|
||||
setTest.do(fun(it: int) println(it);)
|
||||
setTest.for_each(fun(it: int) println(it);)
|
||||
println("delete")
|
||||
setTest.remove(2)
|
||||
setTest.do(fun(it: int) println(it);)
|
||||
setTest.for_each(fun(it: int) println(it);)
|
||||
|
||||
println("delete v2")
|
||||
var firstRem.construct(100): AbleToBeDestroyed;
|
||||
|
||||
Reference in New Issue
Block a user