-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNFATest.cs
More file actions
34 lines (30 loc) · 939 Bytes
/
NFATest.cs
File metadata and controls
34 lines (30 loc) · 939 Bytes
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
using UnityEngine;
using Xtaieer.Automaton.Nfa;
using Xtaieer.Regular;
using Xtaieer.Automaton;
public class NFATest : MonoBehaviour
{
[SerializeField]
private string regular;
[SerializeField]
private string str;
[ContextMenu("Test")]
private void Test()
{
//(+|-)?([1-9][0-9]*|0)(.[0-9]*)?
RegularParser parser = new RegularParser();
IRegularExpression exp = parser.Parse(regular);
RegularPrinter printer = new RegularPrinter();
exp.Accept(printer);
printer.Result();
}
[ContextMenu("Match")]
private void Match()
{
RegularParser parser = new RegularParser();
IRegularExpression exp = parser.Parse(regular);
NFADirector director = new NFADirector();
IAutomaton automaton = director.Generate(exp, new NFABuilder());
// Debug.Log(automaton.IsAccept(str));
}
}