summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2015-12-08 21:53:34 +0200
committerOskari Timperi <oskari.timperi@iki.fi>2015-12-08 21:53:34 +0200
commit0f2864bdeefeb208e1bb8db6d5cc3c6188f353e0 (patch)
tree6850c4397c579db42fcaa1d3be1c73691345b11b
parentd6d401c83f186e72a105821e60a856ca4d5c998c (diff)
downloadlbasi-0f2864bdeefeb208e1bb8db6d5cc3c6188f353e0.tar.gz
lbasi-0f2864bdeefeb208e1bb8db6d5cc3c6188f353e0.zip
move SkipWhiteSpace and AtEnd out from GetNextToken to Interpreter
-rw-r--r--calc1.pas24
1 files changed, 13 insertions, 11 deletions
diff --git a/calc1.pas b/calc1.pas
index 0757421..eaad650 100644
--- a/calc1.pas
+++ b/calc1.pas
@@ -40,6 +40,8 @@ type
constructor Create(Text_: AnsiString);
procedure Error;
+ procedure SkipWhitespace;
+ function AtEnd: Boolean;
function GetNextToken: Token;
procedure Eat(T: TokenType);
function Expr: Integer;
@@ -97,22 +99,22 @@ begin
Raise Exception.Create('error!');
end;
+procedure Interpreter.SkipWhitespace;
+begin
+ while (not AtEnd) and IsWhiteSpace(Text[CurPos]) do
+ Inc(CurPos);
+end;
+
+function Interpreter.AtEnd: Boolean;
+begin
+ Result := CurPos > Length(Text);
+end;
+
function Interpreter.GetNextToken: Token;
var
Text_: String;
CurrentChar: Char;
Start: Integer;
-
- procedure SkipWhitespace;
- begin
- while (CurPos <= Length(Text)) and IsWhiteSpace(Text[CurPos]) do
- Inc(CurPos);
- end;
-
- function AtEnd: Boolean;
- begin
- Result := CurPos > Length(Text);
- end;
begin
SkipWhitespace;