diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2015-12-08 21:53:34 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2015-12-08 21:53:34 +0200 |
| commit | 0f2864bdeefeb208e1bb8db6d5cc3c6188f353e0 (patch) | |
| tree | 6850c4397c579db42fcaa1d3be1c73691345b11b | |
| parent | d6d401c83f186e72a105821e60a856ca4d5c998c (diff) | |
| download | lbasi-0f2864bdeefeb208e1bb8db6d5cc3c6188f353e0.tar.gz lbasi-0f2864bdeefeb208e1bb8db6d5cc3c6188f353e0.zip | |
move SkipWhiteSpace and AtEnd out from GetNextToken to Interpreter
| -rw-r--r-- | calc1.pas | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -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; |
