本文整理汇总了C#中ParseResult类的典型用法代码示例。如果您正苦于以下问题:C# ParseResult类的具体用法?C# ParseResult怎么用?C# ParseResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseResult类属于命名空间,在下文中一共展示了ParseResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Parse
public override ParseResult Parse(List<Token> tokens, int startLocation)
{
// Head part
var head = termParser.Parse(tokens, startLocation);
if (!head.Succeed) head = termProductParser.Parse(tokens, startLocation);
if (!head.Succeed)
{
head.ErrorMessage = "Expected reduction rule head term or term product: " + head.ErrorMessage;
return head;
}
// Arrow
if (head.NextParsePosition >= tokens.Count
|| tokens[head.NextParsePosition].TokenType != TokenType.Arrow)
{
var arrowError = new ParseResult(tokens, head.NextParsePosition);
arrowError.ErrorMessage = "Expected reduction rule arrow symbol";
return arrowError;
}
// Tail part
var tail = termParser.Parse(tokens, head.NextParsePosition + 1);
if (!tail.Succeed)
{
tail.ErrorMessage = "Expected reduction rule tail term: " + tail.ErrorMessage;
return tail;
}
var reductionRule = new ParseResult(tokens, startLocation);
reductionRule.AstResult = new AstReductionRule((AstTermBase)head.AstResult, (AstTermBase)tail.AstResult);
reductionRule.NextParsePosition = tail.NextParsePosition;
return reductionRule;
}
开发者ID:WCoetser,项目名称:TRL,代码行数:30,代码来源:ReductionRuleParser.cs
示例2: ProcessExecutedTask
/// <summary>
///
/// </summary>
/// <param name="task"></param>
/// <param name="pr"></param>
public void ProcessExecutedTask(Task task, ParseResult pr)
{
if (pr.Success)
{
if (StringHelper.Equal(task.Device.DeviceDefine.DeviceType,
DeviceDefineConst.DDT_XD221Modbus))
{
XD221ModbusProcessor.Default.ProcessExecutedTask(task, pr);
}
// xd221
//
if (StringHelper.Equal(task.Device.DeviceDefine.DeviceType,
DeviceDefineConst.DDT_XD221))
{
XD221Processor.Defalut.ProcessExecutedTask(task, pr);
}
// xd202
//
if (StringHelper.Equal(task.Device.DeviceDefine.DeviceType,
DeviceDefineConst.DDT_XD202))
{
XD202Processor.Default.ProcessExecutedTask(task, pr);
}
}
// xd2300
//
if (StringHelper.Equal(task.Device.DeviceType,
DeviceDefineConst.DDT_XD2300))
{
XD2300Processor.Default.ProcessExecutedTask(task, pr);
}
}
开发者ID:hkiaipc,项目名称:yh,代码行数:40,代码来源:YeHeProcessor.cs
示例3: ParseFile
public ParseResult<Person> ParseFile(string filePath, char delimiter)
{
//Opens the file
var parseResult = new ParseResult<Person>();
var reader = File.OpenText(filePath);
var line = "";
//Reads each line
while ((line = reader.ReadLine()) != null)
{
//Creates an array based on our delimiter
var fieldArray = line.Split(delimiter);
//Maps the array to a concrete object
var personFromFile = new Person
{
LastName = fieldArray[0],
FirstName = fieldArray[1],
Birthday = DateTime.Parse(fieldArray[2])
};
//Perform some validation (method below)
var validationResult = ValidatePerson(personFromFile, line);
AddValidObjectOrParseErrorToResults(validationResult, parseResult, personFromFile, line);
}
return parseResult;
}
开发者ID:tgkuzma,项目名称:SRP,代码行数:30,代码来源:AllInOneFileParser.cs
示例4: GetTags
public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {
foreach (var taskDef in parseResult.SyntaxTree.GetRoot().DescendantNodes<TaskDefinitionSyntax>()) {
var extent = taskDef.Extent;
var nameToken = taskDef.Identifier;
if (nameToken.IsMissing) {
continue;
}
var rgnStartToken = nameToken.NextToken();
if (rgnStartToken.IsMissing) {
continue;
}
var start = Math.Min(nameToken.End + 1, rgnStartToken.Start);
int length = extent.End - start;
if (length <= 0) {
continue;
}
var regionSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, start), length);
var hintSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
var tag = tagCreator.CreateTag("...", hintSpan);
yield return new TagSpan<IOutliningRegionTag>(regionSpan, tag);
}
}
开发者ID:IInspectable,项目名称:Nav.Language.Extensions,代码行数:30,代码来源:TaskDefinitionsOutlineTagger.cs
示例5: GetTags
public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {
var transitionBlocks = parseResult.SyntaxTree.GetRoot().DescendantNodes().OfType<TransitionDefinitionBlockSyntax>();
foreach (var transitionBlock in transitionBlocks) {
var extent = transitionBlock.Extent;
if (extent.IsEmptyOrMissing) {
continue;
}
var startLine = parseResult.Snapshot.GetLineNumberFromPosition(extent.Start);
var endLine = parseResult.Snapshot.GetLineNumberFromPosition(extent.End);
if (startLine == endLine) {
continue;
}
var collapsedForm = "Transitions";
var rgnSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
var hintSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
var rgnTag = tagCreator.CreateTag(collapsedForm, hintSpan);
yield return new TagSpan<IOutliningRegionTag>(rgnSpan, rgnTag);
}
}
开发者ID:IInspectable,项目名称:Nav.Language.Extensions,代码行数:25,代码来源:TransitionDefinitionBlockOutlineTagger.cs
示例6: GetTags
public static IEnumerable< ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {
var usingDirectives = parseResult.SyntaxTree.GetRoot().DescendantNodes<CodeUsingDeclarationSyntax>().ToList();
if (usingDirectives.Count<2) {
yield break;
}
var firstUsing = usingDirectives[0];
var lastUsing = usingDirectives[usingDirectives.Count - 1];
var usingKeyword = firstUsing.UsingKeyword;
if (usingKeyword.IsMissing) {
yield break;
}
var extendStart = firstUsing.Extent;
var extendEnd = lastUsing.Extent;
var start = usingKeyword.End + 1;
int length = extendEnd.End - start - 1; // Letzte ] noch mit anzeigen..
if (length <= 0) {
yield break;
}
var regionSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, start), length);
var hintSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extendStart.Start), extendEnd.End- extendStart.Start);
var tag = tagCreator.CreateTag("...", hintSpan);
yield return new TagSpan<IOutliningRegionTag>(regionSpan, tag);
}
开发者ID:IInspectable,项目名称:Nav.Language.Extensions,代码行数:31,代码来源:CodeUsingDirectiveOutlineTagger.cs
示例7: ProcessExecutedTask
/// <summary>
///
/// </summary>
/// <param name="task"></param>
/// <param name="pr"></param>
public void ProcessExecutedTask(Task task, ParseResult pr)
{
int instantFlux = Convert.ToInt32(pr.NameObjects.GetObject("IF"));
// remain amount out int32 range
//
int remainAmount = 0;
object remainAmountObject = pr.NameObjects.GetObject("RemainAmount");
Debug.Assert(remainAmountObject != null, "remianAmountObject == null");
try
{
remainAmount = Convert.ToInt32(remainAmountObject);
}
catch (Exception )
{
}
//int remainAmount = 0;
int beforeWL = Convert.ToInt32(pr.NameObjects.GetObject("WL1"));
int behindWL = Convert.ToInt32(pr.NameObjects.GetObject("WL2"));
int height = Convert.ToInt32(pr.NameObjects.GetObject("Height"));
XD202Data data = new XD202Data(instantFlux, remainAmount, height, beforeWL, behindWL);
XD202Device d = task.Device as XD202Device;
d.XD202Data = data;
// TODO:
//
DB.MeasureSluiceData.Insert(d, data);
}
开发者ID:hkiaipc,项目名称:hunb,代码行数:36,代码来源:XD202Processor.cs
示例8: Parse
/// <summary>
/// 解析新浪视频视频文件源地址
/// </summary>
public ParseResult Parse(ParseRequest request)
{
ParseResult pr = new ParseResult();
//合并完整url
string url = @"http://v.iask.com/v_play.php?vid=" + request.Id;
string source = Network.GetHtmlSource(url, Encoding.UTF8, request.Proxy);
//视频总长度
string totallength = Regex.Match(source, @"<timelength>(?<timelength>\d+)</timelength>").Groups["timelength"].Value;
//Framecount
string framecount = Regex.Match(source, @"<framecount>(?<framecount>\d+)</framecount>").Groups["framecount"].Value;
//src
string src = Regex.Match(source, @"<src>(?<src>\d+)</src>").Groups["src"].Value;
pr.SpecificResult.Add("totallength", totallength);
pr.SpecificResult.Add("framecount", framecount);
pr.SpecificResult.Add("src", src);
//vstr
string vstr = Regex.Match(source, @"(?<=<vstr><!\[CDATA\[)\w+").Value;
//视频信息
Regex r = new Regex(@"<durl>.+?<order>(?<order>\d+)</order>.+?<length>(?<length>\d+)</length>.+?<url><!\[CDATA\[(?<url>.+?)\]\]></url>.+?</durl>", RegexOptions.Singleline);
MatchCollection matches = r.Matches(source);
foreach (Match item in matches)
{
var pri = new ParseResultItem();
pri.RealAddress = new Uri(item.Groups["url"].Value +
(string.IsNullOrEmpty(vstr) ? "" : "?vstr=" + vstr));
pri.Information.Add("order", item.Groups["order"].Value);
pri.Information.Add("length", item.Groups["length"].Value);
pr.Items.Add(pri);
}
//返回结果
return pr;
}
开发者ID:renning22,项目名称:SnifferPlayer,代码行数:38,代码来源:SinaVideoParser.cs
示例9: Parse
/// <summary>
/// 解析任意视频源地址
/// </summary>
public ParseResult Parse(ParseRequest request)
{
//返回值
ParseResult pr = new ParseResult();
//分辨率
string resolution = request.SpecificConfiguration.ContainsKey("resolution") ? request.SpecificConfiguration["resolution"] : "";
//修正url
string url = "http://www.flvcd.com/parse.php?kw=" + Tools.UrlEncode(request.Id) + resolution;
//取得网页源文件
string src = Network.GetHtmlSource(url, Encoding.GetEncoding("GB2312"), request.Proxy);
//检查是否需要密码
if (src.Contains("请输入密码"))
{
url = url + "&passwd=" + request.Password;
src = Network.GetHtmlSource(url, Encoding.GetEncoding("GB2312"), request.Proxy);
}
//取得内容
Regex rContent = new Regex("<input type=\"hidden\" name=\"inf\".+\">", RegexOptions.Singleline);
Match mContent = rContent.Match(src);
string content = mContent.Value;
//取得各Part下载地址
List<string> partUrls = new List<string>();
Regex rPartUrls = new Regex(@"<U>(?<url>.+)");
MatchCollection mcPartUrls = rPartUrls.Matches(content);
foreach (Match item in mcPartUrls)
{
pr.Items.Add(new ParseResultItem() { RealAddress = new Uri(item.Groups["url"].Value) });
}
return pr;
}
开发者ID:renning22,项目名称:SnifferPlayer,代码行数:37,代码来源:FlvcdParser.cs
示例10: AssertDoubleTryParse
private void AssertDoubleTryParse(string s, ParseResult expectedResult, double? expectedValue)
{
double d;
char[] c = s.ToCharArray();
ParseResult result = ConvertUtils.DoubleTryParse(c, 0, c.Length, out d);
double d2;
bool result2 = double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out d2)
&& !s.StartsWith(".")
&& !s.EndsWith(".")
&& !(s.StartsWith("0") && s.Length > 1 && !s.StartsWith("0.") && !s.StartsWith("0e", StringComparison.OrdinalIgnoreCase))
&& !(s.StartsWith("-0") && s.Length > 2 && !s.StartsWith("-0.") && !s.StartsWith("-0e", StringComparison.OrdinalIgnoreCase))
&& s.IndexOf(".e", StringComparison.OrdinalIgnoreCase) == -1;
Assert.AreEqual(expectedResult, result);
Assert.AreEqual(expectedResult == ParseResult.Success, result2);
if (result2)
{
Assert.IsTrue(expectedValue.HasValue);
Assert.AreEqual(expectedValue.Value, d, "Input string: " + s);
Assert.AreEqual(expectedValue.Value, d2, "DoubleTryParse result is not equal to double.Parse. Input string: " + s);
}
}
开发者ID:JamesNK,项目名称:Newtonsoft.Json,代码行数:26,代码来源:ConvertUtilsTests.cs
示例11: ProcessExecutedTask
/// <summary>
///
/// </summary>
/// <param name="task"></param>
/// <param name="pr"></param>
public void ProcessExecutedTask(Task task, ParseResult pr)
{
if (StringHelper.Equal(task.Opera.Name, OperaNames.ReadReal))
{
//
// 功能码: 0x10
// 数据数: 0位
// 成功后返回: 0x21+0x58+0x44+地址+0x80+功能码+0x12+日期+时间+已用水量+瞬时流量+闸前水位+闸后水位+CRC16
// 日期(3字节BCD码 年+月+日)
// 时间(3字节BCD码 时+分+秒)
// 已用水量(4字节)(无符号整型)带一位小数点 m3 <b>
// 瞬时流量(4字节)(无符号整型)带一位小数点 m3/h <c>
// 闸前水位(2字节)带两位小数点 m <a>
// 闸后水位(2字节)带两位小数点 m
//
// 供电电压 (2Byte) 两位小数点 <d>
// 水位, 单位CM, <a>
//
int wl1 = (Int16)pr.NameObjects.GetObject("WL1");
int wl2 = (Int16)pr.NameObjects.GetObject("WL2");
uint instantFlux = (UInt32)pr.NameObjects.GetObject("IF");
uint usedAmount = (uint)pr.NameObjects.GetObject("usedAmount");
object objTemp = pr.NameObjects.GetObject("voltage");
int voltage = Convert.ToInt32(objTemp);
// <c>
//
instantFlux = (uint)(instantFlux / 10);
// <b>
//
usedAmount = (uint)(usedAmount / 10);
// <d>
//
voltage = voltage / 100;
if (Config.Default.IsUseFluxFormula)
{
instantFlux = (uint)YeHeCommuniServerApp.Default.DevieFormaulCollectionMapCollection.CalcInstantFlux(
task.Device.ID, DateTime.Now, wl1, wl2);
}
DitchDevice ditchDevice = task.Device as DitchDevice;
ditchDevice.DitchData = new DitchData(wl1, wl2, instantFlux, usedAmount, voltage);
DB.DitchDataDBI.Insert(ditchDevice, DateTime.Now, instantFlux, wl1, wl2, usedAmount, voltage);
}
//if (StringHelper.Equal(task.Opera.Name, OperaNames.ReadParams))
//{
// XD221Params p = ProcessParams(pr);
// XD221Device xd221Device = task.Device as XD221Device;
// xd221Device.Xd221Params = p;
//}
}
开发者ID:hkiaipc,项目名称:yh,代码行数:63,代码来源:XD221Processor.cs
示例12: OpEquality_WithNullReferenceOnRight_ReturnsFalse
public void OpEquality_WithNullReferenceOnRight_ReturnsFalse()
{
var start = new Cursor("OK", 0);
var end = start.Advance(1);
var subjectA = new ParseResult<int>(start, end, 0);
var subjectB = (ParseResult<int>)null;
Assert.That(subjectA == subjectB, Is.False);
}
开发者ID:KevinKelley,项目名称:Pegasus,代码行数:9,代码来源:ParseResultTests.cs
示例13: OpEquality_WithEqualValuesAndCursors_ReturnsTrue
public void OpEquality_WithEqualValuesAndCursors_ReturnsTrue()
{
var start = new Cursor("OK", 0);
var end = start.Advance(1);
var subjectA = new ParseResult<int>(start, end, 0);
var subjectB = new ParseResult<int>(start, end, 0);
Assert.That(subjectA == subjectB, Is.True);
}
开发者ID:KevinKelley,项目名称:Pegasus,代码行数:9,代码来源:ParseResultTests.cs
示例14: Equals_WithOtherObject_ReturnsFalse
public void Equals_WithOtherObject_ReturnsFalse()
{
var start = new Cursor("OK", 0);
var end = start.Advance(1);
var subjectA = new ParseResult<int>(start, end, 0);
var subjectB = new object();
Assert.That(subjectA.Equals(subjectB), Is.False);
}
开发者ID:KevinKelley,项目名称:Pegasus,代码行数:9,代码来源:ParseResultTests.cs
示例15: GetHashCode_WithEqualValuesAndCursors_ReturnsSameValue
public void GetHashCode_WithEqualValuesAndCursors_ReturnsSameValue([Values(0, 1, 2)] int index)
{
var start = new Cursor("OK");
var end = start.Advance(index);
var subjectA = new ParseResult<int>(start, end, 0);
var subjectB = new ParseResult<int>(start, end, 0);
Assert.That(subjectB.GetHashCode(), Is.EqualTo(subjectA.GetHashCode()));
}
开发者ID:otac0n,项目名称:Pegasus,代码行数:9,代码来源:ParseResultTests.cs
示例16: Call
public override void Call(ParseResult parseResult, object values, string optionString)
{
var newValues =
parseResult.Get<IEnumerable>(Destination, new object[] {})
.Cast<object>()
.Concat(new[] {values})
.ToArray();
parseResult[Destination] = newValues;
}
开发者ID:CrOrc,项目名称:Cr.ArgParse,代码行数:9,代码来源:AppendAction.cs
示例17: Strategy
public override int Strategy(ParseResult parseResult)
{
_recoveryPerformanceData.Timer.Start();
var res = base.Strategy(parseResult);
_recoveryPerformanceData.Timer.Stop();
return res;
}
开发者ID:hwwang,项目名称:Nitra,代码行数:9,代码来源:RecoveryVisualizer.cs
示例18: FindMember
private static Member FindMember(Domain domain, ParseResult result)
{
var member = FindRootMember(domain, result[0]);
for (var i = 1; i < result.ChildCount; ++i) {
member = member.FindMember(domain, result[i]);
}
return member;
}
开发者ID:katalist5296,项目名称:SanAndreasUnity,代码行数:10,代码来源:ReflectionCommands.cs
示例19: OpEquality_WithUnequalEndCursors_ReturnsFalse
public void OpEquality_WithUnequalEndCursors_ReturnsFalse()
{
var start = new Cursor("OK", 0);
var one = start.Advance(1);
var two = one.Advance(1);
var subjectA = new ParseResult<int>(start, one, 0);
var subjectB = new ParseResult<int>(start, two, 0);
Assert.That(subjectA == subjectB, Is.False);
}
开发者ID:KevinKelley,项目名称:Pegasus,代码行数:10,代码来源:ParseResultTests.cs
示例20: AddParseResultToList
void AddParseResultToList(ParseResult pr)
{
var item = listView1.Items.Add(pr.Text);
item.SubItems.Add(pr.StartPos.ToString());
item.SubItems.Add(pr.Type.Description());
if (pr.Value != null)
{
item.SubItems.Add(pr.Value.GetType().Name);
item.SubItems.Add(pr.Value.ToString());
}
}
开发者ID:ravindrapro,项目名称:nepy,代码行数:11,代码来源:Form1.cs
注:本文中的ParseResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论