Stream track current tab depth

This commit is contained in:
2024-12-11 10:53:02 -06:00
parent 6ec40da338
commit 8e3bb78829

View File

@@ -125,15 +125,20 @@ class Stream {
public function dropChars(count:Int, taking:Bool) { public function dropChars(count:Int, taking:Bool) {
for (idx in 0...count) { for (idx in 0...count) {
switch (content.charAt(idx)) { switch (content.charAt(idx)) {
// newline
case "\n": case "\n":
_currentTab = "";
absoluteChar += absolutePerNewline; absoluteChar += absolutePerNewline;
line += 1; line += 1;
lineLengths.push(column); lineLengths.push(column);
column = 1; column = 1;
startOfLine = true; startOfLine = true;
// other whitespace character
case c if (c.trim() == ""): case c if (c.trim() == ""):
_currentTab += c;
absoluteChar += 1; absoluteChar += 1;
column += 1; column += 1;
// non-whitespace
default: default:
absoluteChar += 1; absoluteChar += 1;
column += 1; column += 1;
@@ -183,6 +188,12 @@ class Stream {
#end #end
} }
var _currentTab = "";
public function currentTab():String {
return _currentTab;
}
public function takeChars(count:Int):Option<String> { public function takeChars(count:Int):Option<String> {
if (count > content.length) if (count > content.length)
return None; return None;