mirror of https://github.com/japl-lang/japl.git
Allow // in test definitions.
This commit is contained in:
parent
960ba879cb
commit
f32c1036c2
|
@ -1,5 +1,7 @@
|
||||||
[Test: fibonacci]
|
|
||||||
[source: raw]
|
//[Test: fibonacci]
|
||||||
|
|
||||||
|
//[source: raw]
|
||||||
fun fib(n) {
|
fun fib(n) {
|
||||||
if (n < 2)
|
if (n < 2)
|
||||||
return n;
|
return n;
|
||||||
|
@ -14,7 +16,8 @@ print(fib(6));
|
||||||
print(fib(7));
|
print(fib(7));
|
||||||
print(fib(8));
|
print(fib(8));
|
||||||
print(fib(9));
|
print(fib(9));
|
||||||
[end]
|
//[end]
|
||||||
|
/*
|
||||||
[stdout]
|
[stdout]
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
|
@ -26,4 +29,5 @@ print(fib(9));
|
||||||
21
|
21
|
||||||
34
|
34
|
||||||
[end]
|
[end]
|
||||||
[end]
|
*/
|
||||||
|
//[end]
|
||||||
|
|
|
@ -30,8 +30,8 @@ proc parseModalLine(line: string): tuple[modal: bool, mode: string, detail: stri
|
||||||
## if comment is true, the returned value has to be ignored
|
## if comment is true, the returned value has to be ignored
|
||||||
# when non modal, mode becomes the line
|
# when non modal, mode becomes the line
|
||||||
# when comment is true, it must not do anything to whenever it is exported
|
# when comment is true, it must not do anything to whenever it is exported
|
||||||
let line = line
|
|
||||||
# initialize result
|
# initialize result
|
||||||
|
var start = 0
|
||||||
result.modal = false
|
result.modal = false
|
||||||
result.mode = ""
|
result.mode = ""
|
||||||
result.detail = ""
|
result.detail = ""
|
||||||
|
@ -48,14 +48,21 @@ proc parseModalLine(line: string): tuple[modal: bool, mode: string, detail: stri
|
||||||
result.modal = true
|
result.modal = true
|
||||||
return result
|
return result
|
||||||
result.modal = true
|
result.modal = true
|
||||||
|
start = 1
|
||||||
# not modal line early return
|
# not modal line early return
|
||||||
|
elif line.len() >= 3 and line[0..2] == "//[":
|
||||||
|
if line.len() > 3:
|
||||||
|
result.modal = true
|
||||||
|
start = 3
|
||||||
|
else:
|
||||||
|
fatal "Invalid line //[, no mode defined."
|
||||||
else:
|
else:
|
||||||
result.mode = line
|
result.mode = line
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# normal modal line:
|
# normal modal line:
|
||||||
var colon = false # if there has been a colon already
|
var colon = false # if there has been a colon already
|
||||||
for i in countup(0, line.high()):
|
for i in countup(start, line.high()):
|
||||||
let ch = line[i]
|
let ch = line[i]
|
||||||
if ch in Letters or ch in Digits or ch in {'_', '-'}:
|
if ch in Letters or ch in Digits or ch in {'_', '-'}:
|
||||||
# legal characters
|
# legal characters
|
||||||
|
|
Loading…
Reference in New Issue