-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringInput.cs
55 lines (46 loc) · 983 Bytes
/
StringInput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Framework.Parsing
{
public class StringInput
{
String _input;
int _pos;
int? _markPos;
public StringInput(string input)
{
_input = input;
}
public bool HasCurrentChar()
{
return _pos < _input.Length;
}
public char CurrentChar()
{
return _input[_pos];
}
public void MoveNextChar()
{
_pos++;
}
public void MarkPos()
{
_markPos = _pos;
}
public void UnmarkPos()
{
_markPos = null;
}
public string GetFromMarkedPos()
{
var text = _input.Substring(_markPos.Value, _pos - _markPos.Value);
return text;
}
public int GetPos()
{
return _pos;
}
}
}