Gathers need not have an expression
This commit is contained in:
11
examples/no-op-gather/main.hank
Normal file
11
examples/no-op-gather/main.hank
Normal file
@@ -0,0 +1,11 @@
|
||||
Hey, you!
|
||||
|
||||
* Hello, world!
|
||||
I just love meeting friendly people.
|
||||
* Goodbye, cruel world!
|
||||
Was it something I said?
|
||||
-
|
||||
|
||||
Some text after this.
|
||||
|
||||
-
|
||||
6
examples/no-op-gather/test1.hlog
Normal file
6
examples/no-op-gather/test1.hlog
Normal file
@@ -0,0 +1,6 @@
|
||||
Hey, you!
|
||||
* Hello, world!
|
||||
* Goodbye, cruel world!
|
||||
> 1: Hello, world!
|
||||
I just love meeting friendly people.
|
||||
Some text after this.
|
||||
@@ -359,8 +359,11 @@ class HankBuffer {
|
||||
return getLine(trimmed, takeUntil, true);
|
||||
}
|
||||
|
||||
public function skipWhitespace() {
|
||||
var whitespace = cleanBuffer.substr(0, cleanBuffer.length - cleanBuffer.ltrim().length);
|
||||
public function skipWhitespace(terminator: String = '') {
|
||||
var nextTerm = cleanBuffer.indexOf(terminator);
|
||||
var withoutTerm = cleanBuffer.length - cleanBuffer.ltrim().length;
|
||||
var end = if (nextTerm <= 0) withoutTerm else Math.floor(Math.min(nextTerm, withoutTerm));
|
||||
var whitespace = cleanBuffer.substr(0, end);
|
||||
drop(whitespace);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,8 +179,15 @@ class Parser {
|
||||
var depth = buffer.countConsecutive('-');
|
||||
buffer.skipWhitespace();
|
||||
var label = buffer.expressionIfNext('(', ')');
|
||||
buffer.skipWhitespace();
|
||||
return EGather(label, depth, parseExpr(buffer, buffer.position()));
|
||||
buffer.skipWhitespace('\n');
|
||||
|
||||
var gatherOp = switch (buffer.peekLine()) {
|
||||
case Some("") | None:
|
||||
ENoOp;
|
||||
default:
|
||||
parseExpr(buffer, buffer.position());
|
||||
}
|
||||
return EGather(label, depth, gatherOp);
|
||||
}
|
||||
|
||||
static var choices: Int = 0;
|
||||
|
||||
Reference in New Issue
Block a user