-
Notifications
You must be signed in to change notification settings - Fork 0
/
Position.cs
50 lines (44 loc) · 1.08 KB
/
Position.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
public class Position {
public int idx {get; private set;} = -1;
public int ln {get; private set;} = 0;
public int col {get; private set;} = -1;
public string fn {get; private set;}
public string ftxt {get; private set;}
public Position(int idxV, int lnV, int colV, string fnV, string ftxtV){
idx = idxV;
ln = lnV;
col = colV;
fn = fnV;
ftxt = ftxtV;
}
public Position(string fnV, string ftxtV){
idx = -1;
ln = 0;
col = -1;
fn = fnV;
ftxt = ftxtV;
}
static public Position Nothing(string ftxt = "")
{
return new Position(0, 0, 0, "<gloabls>", "");
}
public void ResetIndexing()
{
idx = -1;
}
public Position Advance(string currentChar = "")
{
this.idx += 1;
this.col += 1;
if (currentChar == "\n")
{
this.ln += 1;
this.col = 0;
}
return this;
}
public Position Copy()
{
return new Position(this.idx, this.ln, this.col, this.fn, this.ftxt);
}
}