-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVStruct.cs
More file actions
66 lines (62 loc) · 1.82 KB
/
Copy pathVStruct.cs
File metadata and controls
66 lines (62 loc) · 1.82 KB
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
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VividScript
{
public enum VStructType
{
Entry,Module,Method,Function,Exit,Unknown
}
public delegate void ParseStructToken(VToken t);
public class VStruct
{
public VStructType Type = VStructType.Unknown;
public string Name = "";
public List<VStruct> Structs = new List<VStruct>();
public int At = 0;
public bool Ran = false;
public long RunCount = 0;
public ParseStructToken PreParser = null;
public ParseStructToken Parser = null;
public bool Done = false;
public VTokenStream TokStream = null;
public VStruct(VTokenStream toks)
{
this.TokStream = toks;
Parse();
}
public virtual void BackOne()
{
TokStream.Pos--;
if (TokStream.Pos < 0) TokStream.Pos = 0;
}
public virtual VToken PeekNext()
{
if (TokStream.Pos >= TokStream.Len) return null;
return TokStream.Tokes[TokStream.Pos];
}
public virtual VToken Peek(int c)
{
c = c - 1;
if (TokStream.Pos + c >= TokStream.Len) return null;
return TokStream.Tokes[TokStream.Pos + c];
}
public virtual void Parse()
{
SetupParser();
if (PreParser != null) PreParser(TokStream.GetNext());
while (TokStream.Pos < TokStream.Len)
{
var nt = PeekNext();
// Console.WriteLine("VS:" + nt.Text + " T:" + nt.Token);
Parser(TokStream.GetNext());
if (Done) return;
}
}
public virtual void SetupParser()
{
}
}
}