##// END OF EJS Templates
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler Any unhandled OperationCanceledException will cause the promise cancelation

File last commit:

r178:d5c5db0335ee ref20160224
r187:dd4a3590f9c6 ref20160224
Show More
RegularExpressionVisitorT.cs
37 lines | 1.2 KiB | text/x-csharp | CSharpLexer
cin
working on JSON parser
r178 using Implab;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Implab.Automaton.RegularExpressions {
/// <summary>
/// </summary>
public class RegularExpressionVisitor<TTag> : RegularExpressionVisitor {
readonly Dictionary<int, TTag> m_tags = new Dictionary<int, TTag>();
readonly ITaggedDFABuilder<TTag> m_builder;
public RegularExpressionVisitor(ITaggedDFABuilder<TTag> builder) : base(builder) {
m_builder = builder;
}
public override void Visit(EndToken token) {
base.Visit(token);
var tagged = token as EndToken<TTag>;
if (tagged != null)
m_tags.Add(Index, tagged.Tag);
}
protected override void MarkFinalState(HashSet<int> state) {
base.MarkFinalState(state);
m_builder.SetStateTag(Translate(state), GetStateTags(state));
}
TTag[] GetStateTags(IEnumerable<int> state) {
Debug.Assert(state != null);
return state.Where(m_tags.ContainsKey).Select(pos => m_tags[pos]).ToArray();
}
}
}