本文整理汇总了C#中System.IO.MemoryStream.TryMatch方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.TryMatch方法的具体用法?C# MemoryStream.TryMatch怎么用?C# MemoryStream.TryMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.TryMatch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchCurlyBraces
private void MatchCurlyBraces(MemoryStream<JavaToken> ts)
{
while (!ts.TryMatch(t => t.Type == JavaTokenType.Operator && t.Value == "}"))
if (ts.TryMatch(t => t.Type == JavaTokenType.Operator && t.Value == "{"))
MatchCurlyBraces(ts);
else
ts.Read();
}
示例2: ParseClassBody
private void ParseClassBody(MemoryStream<JavaToken> ts)
{
while (!ts.TryMatch(t => t.Type == JavaTokenType.Operator && t.Value == "}"))
{
int pos = ts.Position;
if (ts.TryMatch(t => t.Type == JavaTokenType.Operator && t.Value == "{"))
MatchCurlyBraces(ts);
else if (ts.TryMatch(t => t.Type == JavaTokenType.Keyword && (t.Value == "public" || t.Value == "protected" || t.Value == "private")))
ParsePossibleMethod(ts, pos);
else
ts.Read();
}
}
示例3: ParsePossibleMethod
private void ParsePossibleMethod(MemoryStream<JavaToken> ts, int pos)
{
while (!ts.TryMatch(t => t.Type == JavaTokenType.Operator && t.Value == ";"))
{
if (ts.TryMatch(t => t.Type == JavaTokenType.Operator && t.Value == "{"))
{
MatchCurlyBraces(ts);
m_MethodBlocks.Add(new JavaMethodBlock(new SimpleTextSpan(m_Tokens[pos].Location.Start, m_Tokens[ts.Position - 1].Location.End)));
return;
}
else
ts.Read();
}
}
示例4: TryParseLVar
protected JavaScriptBlock TryParseLVar(MemoryStream<JavaScriptToken> ts)
{
int before = ts.Position;
if (ts.TryMatch((token) => token.Type == JavaScriptTokenType.Identifier))
{
JavaScriptBlock block = new JavaScriptBlock(before, JavaScriptBlockType.LVar, this, m_TopLevel, m_Tokens);
while (true)
{
while (block.TryParseBrackets(ts, "[", "]") != null)
;
if (!ts.TryMatch((token) => token.Type == JavaScriptTokenType.Operator && token.Value == "."))
break;
if (!ts.TryMatch((token) => token.Type == JavaScriptTokenType.Identifier))
break;
}
block.m_SubBlocks.Clear(); // Don't want sub blocks in LVar blocks.
AddBlock(block, ts);
return block;
}
return null;
}
示例5: TryParseFunction
protected JavaScriptBlock TryParseFunction(MemoryStream<JavaScriptToken> ts)
{
int before = ts.Position;
if (ts.TryMatch((token) => token.Type == JavaScriptTokenType.Keyword && token.Value == "function"))
{
JavaScriptBlock block = new JavaScriptBlock(before, JavaScriptBlockType.Function, this, m_TopLevel, m_Tokens);
block.TryMatchComments(ts);
block.TryParseLVar(ts); // Too generic for optional function name, but never mind
block.TryMatchComments(ts);
block.TryParseBrackets(ts, "(", ")");
block.TryMatchComments(ts);
block.m_FunctionBody = block.TryParseBrackets(ts, "{", "}");
AddBlock(block, ts);
return block;
}
return null;
}
示例6: TryParseBrackets
protected JavaScriptBlock TryParseBrackets(MemoryStream<JavaScriptToken> ts, string ch, string endCh)
{
int before = ts.Position;
if (ts.TryMatch((token) => token.Type == JavaScriptTokenType.Operator && token.Value == ch))
{
JavaScriptBlock block = new JavaScriptBlock(before, JavaScriptBlockType.Brackets, this, m_TopLevel, m_Tokens);
block.TryParseAny(ts, (token) => token.Type == JavaScriptTokenType.Operator && token.Value == endCh);
ts.Read();
AddBlock(block, ts);
return block;
}
return null;
}
示例7: TryMatchComments
protected void TryMatchComments(MemoryStream<JavaScriptToken> ts)
{
while (ts.TryMatch(token => token.Type == JavaScriptTokenType.Comment || token.Type == JavaScriptTokenType.MultiLineComment))
;
}
示例8: ParseStream
private void ParseStream(MemoryStream<JavaToken> ts)
{
while (true)
{
if (ts.TryMatch(t => t.Type == JavaTokenType.Keyword && t.Value == "class"))
ParseClass(ts);
else
ts.Read();
}
}
示例9: ParseClass
private void ParseClass(MemoryStream<JavaToken> ts)
{
while (!ts.TryMatch(t => t.Type == JavaTokenType.Operator && t.Value == "{"))
ts.Read();
ParseClassBody(ts);
}