本文整理汇总了C#中ParseState类的典型用法代码示例。如果您正苦于以下问题:C# ParseState类的具体用法?C# ParseState怎么用?C# ParseState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseState类属于命名空间,在下文中一共展示了ParseState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseException
public ParseState this[ParseState current, BnfTerm symbol]
{
get
{
Dictionary<BnfTerm, ParseState> transition;
if (!transitionRules.TryGetValue(current, out transition))
{
if (!allStates.Contains(current))
throw new ParseException("No such state");
else
return null;
}
ParseState next;
if (!transition.TryGetValue(symbol, out next))
{
HashSet<Terminal> expected = new HashSet<Terminal>();
foreach (var item in current)
{
if (item.Position < item.Production.Body.Length)
expected.UnionWith(grammar.GetFirstSet(item.Production.Body[item.Position]));
}
throw new ParseException("Invalid symbol " + symbol.ToString() + " expected one of [" + String.Join(", ", expected.Select(a => a.Name)) + "]");
}
return next;
}
}
开发者ID:martindevans,项目名称:Hermes,代码行数:29,代码来源:Automaton.cs
示例2: NodeState
public NodeState(ParseState state, int level)
{
Level = level;
Parents = state.Parents;
Root = state.Root;
FilePath = state.FilePath;
}
开发者ID:yonglehou,项目名称:docfx,代码行数:7,代码来源:MarkdownTocReader.cs
示例3: Parse
public static Node Parse(ParseState parsestate)
{
Operator @operator = parsestate.CurrentOperator;
if (@operator != Operator.Equals && @operator != Operator.NotEquals) return null;
parsestate.BaseNode.Arguments.Add(@operator);
++parsestate.TokenIndex;
AttackStateType ast = parsestate.ConvertCurrentToken<AttackStateType>();
if (ast == AttackStateType.None) return null;
parsestate.BaseNode.Arguments.Add(ast);
++parsestate.TokenIndex;
List<Combat.HitType> hittypes = new List<Combat.HitType>();
while (true)
{
if (parsestate.CurrentSymbol != Symbol.Comma) break;
++parsestate.TokenIndex;
Combat.HitType? hittype = parsestate.ConvertCurrentToken<Combat.HitType?>();
if (hittype == null)
{
--parsestate.TokenIndex;
break;
}
hittypes.Add(hittype.Value);
++parsestate.TokenIndex;
}
parsestate.BaseNode.Arguments.Add(hittypes.ToArray());
return parsestate.BaseNode;
}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:35,代码来源:HitDefAttr.cs
示例4: Parse
public static Node Parse(ParseState parsestate)
{
Operator @operator = parsestate.CurrentOperator;
switch (@operator)
{
case Operator.Equals:
case Operator.NotEquals:
case Operator.Greater:
case Operator.GreaterEquals:
case Operator.Lesser:
case Operator.LesserEquals:
++parsestate.TokenIndex;
break;
default:
return null;
}
Node child1 = parsestate.BuildNode(true);
if (child1 == null) return null;
if (parsestate.CurrentSymbol != Symbol.Comma) return null;
++parsestate.TokenIndex;
Node child2 = parsestate.BuildNode(true);
if (child2 == null) return null;
parsestate.BaseNode.Children.Add(child1);
parsestate.BaseNode.Children.Add(child2);
return parsestate.BaseNode;
}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:32,代码来源:TimeMod.cs
示例5: Parse
public static Node Parse(ParseState parsestate)
{
if (parsestate.CurrentSymbol != Symbol.LeftParen) return null;
++parsestate.TokenIndex;
Node c1 = parsestate.BuildNode(true);
if (c1 == null) return null;
parsestate.BaseNode.Children.Add(c1);
if (parsestate.CurrentSymbol != Symbol.Comma) return null;
++parsestate.TokenIndex;
Node c2 = parsestate.BuildNode(true);
if (c2 == null) return null;
parsestate.BaseNode.Children.Add(c2);
if (parsestate.CurrentSymbol != Symbol.Comma) return null;
++parsestate.TokenIndex;
Node c3 = parsestate.BuildNode(true);
if (c3 == null) return null;
parsestate.BaseNode.Children.Add(c3);
if (parsestate.CurrentSymbol != Symbol.RightParen) return null;
++parsestate.TokenIndex;
return parsestate.BaseNode;
}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:28,代码来源:IfElse.cs
示例6: GetNextToken
public bool GetNextToken(TokenInfo tokenInfo, ref ParseState state)
{
bool foundToken = false;
int index = _offset;
if (index >= _source.Length) return false;
int endIndex = -1;
switch (state)
{
case ParseState.InSingleQuotes:
state = HandleSingleQuotes(out endIndex, ref foundToken);
break;
case ParseState.InDoubleQuotes:
state = HandleDoubleQuotes(out endIndex, ref foundToken);
break;
case ParseState.InSingleQuoteHeredoc:
state = HandleHeredoc('\'', state, out endIndex);
break;
case ParseState.InDoubleQuoteHeredoc:
state = HandleHeredoc('"', state, out endIndex);
break;
case ParseState.InBlockComment:
state = HandleBlockComment(out endIndex);
break;
case ParseState.InText:
state = HandleToken(ref foundToken, ref endIndex);
break;
}
tokenInfo.EndIndex = endIndex;
_offset = endIndex + 1;
return foundToken;
}
开发者ID:markrendle,项目名称:CoffeeScriptVS,代码行数:33,代码来源:CoffeeScriptParser.cs
示例7: CborMapReader
/// <summary>
/// Initializes a new instance of the <see cref="CborMapReader"/> class.
/// </summary>
/// <param name="reader">
/// The reader.
/// </param>
/// <param name="size">
/// The size.
/// </param>
/// <param name="targeType">
/// The targe type.
/// </param>
public CborMapReader(CborReader reader, int size, Type targeType)
: base(reader)
{
this.currentSize = size;
this.state = ParseState.FIRST_KEY;
this.dictionary = (IDictionary)Activator.CreateInstance(targeType);
}
开发者ID:naphaso,项目名称:cbor-cs,代码行数:19,代码来源:CborMapReader.cs
示例8: ErrorState
public ErrorState(ParseState state, int level, string message)
{
Level = level;
Parents = state.Parents;
Root = state.Root;
FilePath = state.FilePath;
Message = message;
}
开发者ID:yonglehou,项目名称:docfx,代码行数:8,代码来源:MarkdownTocReader.cs
示例9: load
public override void load()
{
base.load();
string[] t_loadedFile = File.ReadAllLines("Content//wtf//settings.ini");
foreach (string t_currentLine in t_loadedFile)
{
if (t_currentLine.Length > 2 && t_currentLine.First() == '[' && t_currentLine.Last() == ']')
{
if (t_currentLine.Equals("[Graphics]"))
{
m_currentParse = ParseState.Settings;
}
}
switch (m_currentParse)
{
case ParseState.Settings:
string[] t_setting = t_currentLine.Split('=');
if (t_setting[0].Equals("ScreenWidth"))
{
Game.getInstance().m_graphics.PreferredBackBufferWidth = int.Parse(t_setting[1]);
}
else if (t_setting[0].Equals("ScreenHeight"))
{
Game.getInstance().m_graphics.PreferredBackBufferHeight = int.Parse(t_setting[1]);
Game.getInstance().m_camera.setZoom(Game.getInstance().getResolution().Y / 720);
}
else if (t_setting[0].Equals("Fullscreen"))
{
Game.getInstance().m_graphics.IsFullScreen = bool.Parse(t_setting[1]);
}
break;
}
Game.getInstance().m_graphics.ApplyChanges();
}
m_levelText = new Text(new Vector2(405, 80), "New Level:", "VerdanaBold", Color.White, false);
m_newLevelName = new TextField(new Vector2(400, 100), 200, 32, true, true, true, 20);
m_buttons.Add(m_btnTFAccept = new Button("btn_textfield_accept", new Vector2(600, 100)));
m_btnTFAccept.m_clickEvent += new Button.clickDelegate(createNewLevel);
try {
m_levelList = Directory.GetFiles("Content//levels//");
} catch (DirectoryNotFoundException) {
System.IO.Directory.CreateDirectory("Content//levels//");
return;
}
int t_count = 0;
foreach (string t_level in m_levelList)
{
string[] t_splitPath = Regex.Split(t_level, "/");
Button t_levelButton = new Button("btn_test_empty", "btn_test_empty", "btn_test_empty", "btn_test_empty",
new Vector2(20, 60 * t_count + 20), t_splitPath[t_splitPath.Length - 1], "VerdanaBold", Color.Black, new Vector2(10, 10));
t_levelButton.m_clickEvent += new Button.clickDelegate(startLevelClick);
m_buttons.Add(t_levelButton);
t_count++;
}
}
开发者ID:Yuma-Shi,项目名称:GLhf,代码行数:58,代码来源:MainMenu.cs
示例10: ParseBuffer
/// <summary>
/// Read buffer data to Data property and initialize buffer.
/// If response has next data,return true.
/// </summary>
/// <param name="size"></param>
/// <returns>If response has next data,return true</returns>
protected override Boolean ParseBuffer(Int32 size)
{
Byte[] bb = this.Buffer;
Int32 tagIndex = 0;
for (int i = 0; i < size; i++)
{
this.Stream.WriteByte(bb[i]);
if (_State == ParseState.TagValidating)
{
if (bb[i] == _TagBytes[tagIndex])
{
tagIndex = tagIndex + 1;
if (_TagBytes.Length == tagIndex)
{
_State = ParseState.LastLine;
}
}
else
{
_State = ParseState.MultiLine;
}
}
else if (_State == ParseState.MultiLine)
{
if (bb[i] == AsciiCharCode.CarriageReturn.GetNumber())
{
_State = ParseState.CarriageReturn;
}
}
else if (_State == ParseState.CarriageReturn)
{
if (bb[i] == AsciiCharCode.LineFeed.GetNumber())
{
tagIndex = 0;
_State = ParseState.TagValidating;
}
else { throw new DataTransferContextException(this); }
}
else if (_State == ParseState.LastLine)
{
if (bb[i] == AsciiCharCode.CarriageReturn.GetNumber())
{
_State = ParseState.LastLineCarriageReturn;
}
}
else if (_State == ParseState.LastLineCarriageReturn)
{
if (bb[i] == AsciiCharCode.LineFeed.GetNumber())
{
return false;
}
else { throw new DataTransferContextException(this); }
}
bb[i] = 0;
}
return true;
}
开发者ID:fengweijp,项目名称:higlabo,代码行数:64,代码来源:ImapDataReceiveContext.cs
示例11: Action
protected override ParserAction Action(ParseState state, Token token, out Production production, out ParseState nextState)
{
var lr0 = base.Action(state, token, out production, out nextState);
if (token != null && lr0 == ParserAction.Reduce && !Grammar.GetFollowSet(production.Head).Contains(token.Terminal))
return ParserAction.Error;
return lr0;
}
开发者ID:martindevans,项目名称:Hermes,代码行数:9,代码来源:SLR1.cs
示例12: CborObjectReader
/// <summary>
/// Initializes a new instance of the <see cref="CborObjectReader"/> class.
/// </summary>
/// <param name="reader">
/// The reader.
/// </param>
/// <param name="innerTemplate">
/// The inner template.
/// </param>
/// <param name="size">
/// The size.
/// </param>
public CborObjectReader(CborReader reader, CborTypeTemplate innerTemplate, int size)
: base(reader)
{
this.template = innerTemplate;
this.currentSize = size;
this.obj = Activator.CreateInstance(this.template.type);
this.state = ParseState.KEY;
this.currentKey = null;
}
开发者ID:naphaso,项目名称:cbor-cs,代码行数:21,代码来源:CborObjectReader.cs
示例13: Create
//
// As required by IConfigurationSectionHandler
//
public object Create(object parent, object configurationContext, XmlNode section) {
// if called through client config don't even load HttpRuntime
if (!HandlerBase.IsServerConfiguration(configurationContext)) {
return null;
}
ParseState parseState = new ParseState();
parseState.SectionName = section.Name;
// the rule is going to be the previous rule followed by a list containing the new rules
parseState.Evaluator = new HttpCapabilitiesDefaultProvider((HttpCapabilitiesDefaultProvider)parent);
int userAgentCacheKeyLength = 0;
// Get the useragent string cachekey length
if (parent != null) {
userAgentCacheKeyLength = ((HttpCapabilitiesDefaultProvider)parent).UserAgentCacheKeyLength;
}
HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "userAgentCacheKeyLength", ref userAgentCacheKeyLength);
if (userAgentCacheKeyLength == 0) {
userAgentCacheKeyLength = _defaultUserAgentCacheKeyLength;
}
parseState.Evaluator.UserAgentCacheKeyLength = userAgentCacheKeyLength;
string browserCapabilitiesProviderType = null;
if (parent != null) {
browserCapabilitiesProviderType = ((HttpCapabilitiesDefaultProvider)parent).BrowserCapabilitiesProviderType;
}
HandlerBase.GetAndRemoveNonEmptyStringAttribute(section, "provider", ref browserCapabilitiesProviderType);
parseState.Evaluator.BrowserCapabilitiesProviderType = browserCapabilitiesProviderType;
// check for random attributes
HandlerBase.CheckForUnrecognizedAttributes(section);
// iterate through XML section in order and apply the directives
ArrayList sublist;
sublist = RuleListFromElement(parseState, section, true);
if (sublist.Count > 0) {
parseState.RuleList.Add(new CapabilitiesSection(CapabilitiesRule.Filter, null, null, sublist));
}
if (parseState.FileList.Count > 0) {
parseState.IsExternalFile = true;
ResolveFiles(parseState, configurationContext);
}
// Add the new rules
parseState.Evaluator.AddRuleList(parseState.RuleList);
return parseState.Evaluator;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:59,代码来源:HttpCapabilitiesSectionHandler.cs
示例14: ParseSource
public void ParseSource(IEnumerable<char> chars)
{
if (_state != ParseState.BeginLine)
throw new NotImplementedException("unexpected state: " + _state.ToString());
foreach (char ch in chars)
_state = AppendChar(ch);
EndChars();
}
开发者ID:namelesstwice,项目名称:NConfiguration,代码行数:10,代码来源:ParseContext.cs
示例15: Parse
protected override IFieldMapper Parse(Func<ProcessingScope, DateTime?> selector, string defaultName,
JobParser parser, ParseState state)
{
return new TimeDimension(
state.AffixName(state.TryGet("Name", defaultName + "Time")),
selector,
inlineFields: state.TryGet<bool>("Inline"),
cultureInfo: parser.DefaultLanguage.CultureInfo,
detailLevel: state.TryGet("Resolution", TimeDetailLevel.Hour, true));
}
开发者ID:vsegrad,项目名称:experience-extractor,代码行数:10,代码来源:TimeFieldFactory.cs
示例16: Parse
public static Node Parse(ParseState parsestate)
{
Axis axis = parsestate.ConvertCurrentToken<Axis>();
if (axis == Axis.None) return null;
++parsestate.TokenIndex;
parsestate.BaseNode.Arguments.Add(axis);
return parsestate.BaseNode;
}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:10,代码来源:HitVel.cs
示例17: Parse
public static Node Parse(ParseState parsestate)
{
if (parsestate.CurrentSymbol != Symbol.Comma) return null;
++parsestate.TokenIndex;
Node child = parsestate.BuildNode(false);
if (child == null) return null;
parsestate.BaseNode.Children.Add(child);
return parsestate.BaseNode;
}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:11,代码来源:Redirection.cs
示例18: Parse
protected override IFieldMapper Parse(Func<ProcessingScope, DateTime?> selector, string defaultName,
JobParser parser, ParseState state)
{
return new DateDimension(
state.AffixName(state.TryGet("Name", defaultName)),
selector,
useDateForKey: state.TryGet("DateKey", true),
inlineFields: state.TryGet("Inline", false),
cultureInfo: parser.DefaultLanguage.CultureInfo,
key: state.TryGet("Key", false),
detailLevel:
state.TryGet("Resolution", DateDetailLevel.Date, true));
}
开发者ID:vsegrad,项目名称:experience-extractor,代码行数:13,代码来源:DateFieldFactory.cs
示例19: Parse
public static Node Parse(ParseState parsestate)
{
Node node = parsestate.BuildParenNumberNode(true);
if (node != null)
{
return node;
}
else
{
parsestate.BaseNode.Children.Add(Node.NegativeOneNode);
return parsestate.BaseNode;
}
}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:13,代码来源:NumTarget.cs
示例20: Parse
public static Node Parse(ParseState parsestate)
{
Operator @operator = parsestate.CurrentOperator;
if (@operator != Operator.Equals && @operator != Operator.NotEquals) return null;
++parsestate.TokenIndex;
String text = parsestate.CurrentUnknown;
if (text == null) return null;
++parsestate.TokenIndex;
parsestate.BaseNode.Arguments.Add(@operator);
parsestate.BaseNode.Arguments.Add(text);
return parsestate.BaseNode;
}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:14,代码来源:TeamMode.cs
注:本文中的ParseState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论