public override bool Match(IParserState p) { while (FirstChild.Match(p)) { } return(true); }
public static HelpText AutoBuild(object options, string usage, IParserState parserState = null, bool addDashesToOption = true) { var title = (AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false).FirstOrDefault(); var version = (AssemblyInformationalVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).FirstOrDefault(); var copyright = (AssemblyCopyrightAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false).FirstOrDefault(); var license = (AssemblyLicenseAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyLicenseAttribute), false).FirstOrDefault(); var help = new HelpText { AdditionalNewLineAfterOption = true, AddDashesToOption = addDashesToOption }; help.AddPreOptionsLine($"{title?.Title} v{version?.InformationalVersion}"); help.AddPreOptionsLine(copyright?.Copyright); help.AddPreOptionsLine(license?.Value); help.AddPreOptionsLine($"USAGE: {usage}"); help.AddOptions(options); if (parserState != null && parserState.Errors.Any()) { var errors = help.RenderParsingErrorsText(options, 2); // indent with two spaces if (!string.IsNullOrEmpty(errors)) { help.AddPostOptionsLine("ERROR:\n"); help.AddPostOptionsLine(errors); } } return(help); }
private void DescribeState(IndentedTextWriter message, IParserState state) { foreach (var item in state.DotItems) { DescribeItem(message, item); message.WriteLine(); } }
public override bool Match(IParserState p) { if (!p.AtEnd()) { p.GotoNext(); return(true); } return(false); }
public Parser(CommandWords newCommands) { //commands moved to a stack commands = new Stack <CommandWords>(); _state = new ParserNormalState(); //commands = newCommands; Push(newCommands); //pushing the new commands NotificationCenter.Instance.addObserver("PlayerWillEnterState", PlayerWillEnterState); }
public override bool Match(IParserState p) { foreach (Rule r in Children) { if (r.Match(p)) { return(true); } } return(false); }
public override bool Match(IParserState p) { int store = p.GetPos(); if (!FirstChild.Match(p)) { throw new ParsingException(p.GetInput(), store, p.GetPos(), FirstChild, Msg); } return(true); }
public void PlayerWillEnterState(Notification notification) { Player player = (Player)notification.Object; Dictionary <string, Object> userInfo = notification.userInfo; IParserState state = (IParserState)userInfo["state"]; if (State.State == ParserState.Character) { player.currentRoom = GameWorld.Instance.Entrance; } State = state; }
public Parser(string id) { Id = id; CurrentState = new InitialState(); while (Location < Id.Length) { CurrentState.Process(this); } if (!string.IsNullOrEmpty(CurrentPart)) { Parts.Enqueue(CurrentPart); } }
///////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates an <see cref="IParseData"/> for the specified <see cref="IParserState"/>. /// </summary> /// <param name="request">The <see cref="IParseRequest"/> that contains data about the requested parsing operation.</param> /// <param name="state">The <see cref="IParserState"/> to examine.</param> /// <returns>The <see cref="IParseData"/> that was created.</returns> protected override IParseData CreateParseData(IParseRequest request, IParserState state) { var parseData = base.CreateParseData(request, state) as IDotNetParseData; if (parseData != null) { return(new CodeLensParseData(parseData)); } else { return(null); } }
public override bool Match(IParserState p) { if (p.AtEnd()) { return(false); } if (p.GetChar() >= mFirst && p.GetChar() <= mLast) { p.GotoNext(); return(true); } return(false); }
public override bool Match(IParserState p) { if (p.AtEnd()) { return(false); } if (p.GetChar() == mData) { p.GotoNext(); return(true); } return(false); }
public override bool Match(IParserState p) { int pos = p.GetPos(); while (!mTerm.Match(p)) { if (!mElem.Match(p)) { p.SetPos(pos); return(false); } } return(true); }
public override bool Match(IParserState p) { int iter = p.GetPos(); foreach (Rule r in Children) { if (!r.Match(p)) { p.SetPos(iter); return(false); } } return(true); }
private static StreamWriter DescribeState( IReportData data, IParserState state, StreamWriter output, string indent) { foreach (var item in state.DotItems) { output.Write(indent); DescribeItem(data, item, output); output.WriteLine(); } return(output); }
public override bool Match(IParserState p) { if (p.AtEnd()) { return(false); } foreach (char c in mData) { if (c == p.GetChar()) { p.GotoNext(); return(true); } } return(false); }
public override bool Match(IParserState p) { if (p.AtEnd()) { return(false); } int pos = p.GetPos(); if (FirstChild.Match(p)) { p.SetPos(pos); return(true); } Debug.Assert(p.GetPos() == pos); return(false); }
public override bool Match(IParserState p) { p.CreateNode(sLabel); // Used just to make sure the position is restored int pos = p.GetPos(); bool result = FirstChild.Match(p); if (result) { p.CompleteNode(); } else { p.AbandonNode(); // As-sure that the position is restored Debug.Assert(p.GetPos() == pos); } return(result); }
/// <summary> /// Advances the token reader to the next statement or block end from where parsing can resume. /// </summary> /// <param name="state">A <see cref="IParserState"/> that provides information about the parser's current state.</param> /// <returns>An <see cref="IParserErrorResult"/> value indicating a result.</returns> private IParserErrorResult AdvanceToStatementOrBlockEnd(IParserState state) { while (!state.TokenReader.IsAtEnd) { // Quit when a statement or block end is reached if ( (state.TokenReader.LookAheadToken.Id == SimpleTokenId.CloseCurlyBrace) || (statement.CanMatch(state)) ) { return(ParserErrorResults.Continue); } // Advance a token state.TokenReader.Advance(); } return(ParserErrorResults.Continue); }
/// <summary> /// Creates a new /// <see cref="CssParserStateController"/> /// instance. /// </summary> /// <param name="baseUrl">the base URL</param> public CssParserStateController(String baseUrl) { if (baseUrl != null && baseUrl.Length > 0) { this.uriResolver = new UriResolver(baseUrl); } styleSheet = new CssStyleSheet(); nestedAtRules = new Stack <CssNestedAtRule>(); storedPropertiesWithoutSelector = new Stack <IList <CssDeclaration> >(); commentStartState = new CommentStartState(this); commendEndState = new CommentEndState(this); commendInnerState = new CommentInnerState(this); unknownState = new UnknownState(this); ruleState = new RuleState(this); propertiesState = new PropertiesState(this); atRuleBlockState = new AtRuleBlockState(this); conditionalGroupAtRuleBlockState = new ConditionalGroupAtRuleBlockState(this); currentState = unknownState; }
public override bool Match(IParserState p) { int pos = p.GetPos(); foreach (char c in mData) { if (p.AtEnd()) { p.SetPos(pos); return(false); } if (p.GetChar() != c) { p.SetPos(pos); return(false); } p.GotoNext(); } return(true); }
public void SetState(IParserState state) { _shortcodeParser.ParserState = state; }
protected void ChangeState(IParserState state) { GetParent().ChangeState(state); }
/// <summary>Sets the current state.</summary> /// <param name="state">the new state</param> private void SetState(IParserState state) { currentState = state; }
private IParserErrorResult DontReportBeforeClosingBrace(IParserState state) { // Commas are not necessary before the closing brace, so ignore it return state.TokenReader.LookAheadToken.Id == JsonTokenId.CloseCurlyBrace ? ParserErrorResults.Ignore : ParserErrorResults.Continue; }
public override bool Match(IParserState p) { FirstChild.Match(p); return true; }
public override bool Match(IParserState p) { if (p.AtEnd()) return false; if (p.GetChar() >= mFirst && p.GetChar() <= mLast) { p.GotoNext(); return true; } return false; }
public override bool Match(IParserState p) { int iter = p.GetPos(); foreach (Rule r in Children) { if (!r.Match(p)) { p.SetPos(iter); return false; } } return true; }
public void ChangeState(IParserState state) { _states.Push(state); }
public override bool Match(IParserState p) { int store = p.GetPos(); if (!FirstChild.Match(p)) throw new ParsingException(p.GetInput(), store, p.GetPos(), FirstChild, Msg); return true; }
public override bool Match(IParserState p) { return mDeleg().Match(p); }
public override bool Match(IParserState p) { p.CreateNode(sLabel); // Used just to make sure the position is restored int pos = p.GetPos(); bool result = FirstChild.Match(p); if (result) { p.CompleteNode(); } else { p.AbandonNode(); // As-sure that the position is restored Debug.Assert(p.GetPos() == pos); } return result; }
private IParserErrorResult AdvanceToStringOrClosingBrace(IParserState state) { // advance either to the start of the next key/value pair, or to the closing brace state.TokenReader.AdvanceTo(JsonTokenId.StringStartDelimiter, JsonTokenId.CloseCurlyBrace); return(ParserErrorResults.Continue); }
public override bool Match(IParserState p) { while (FirstChild.Match(p)) { } return true; }
public override bool Match(IParserState p) { if (p.AtEnd()) return false; foreach (char c in mData) { if (c == p.GetChar()) { p.GotoNext(); return true; } } return false; }
public override bool Match(IParserState p) { if (!FirstChild.Match(p)) return false; while (FirstChild.Match(p)) { } return true; }
public override bool Match(IParserState p) { int pos = p.GetPos(); while (!mTerm.Match(p)) { if (!mElem.Match(p)) { p.SetPos(pos); return false; } } return true; }
/// <summary> /// Returns true if the rule matches the sub-string starting at the current location /// in the parser object. /// </summary> /// <param name="p"></param> /// <returns></returns> public abstract bool Match(IParserState p);
private IParserErrorResult AdvanceToStringOrClosingBrace(IParserState state) { // advance either to the start of the next key/value pair, or to the closing brace state.TokenReader.AdvanceTo(JsonTokenId.StringStartDelimiter, JsonTokenId.CloseCurlyBrace); return ParserErrorResults.Continue; }
public override bool Match(IParserState p) { return p.AtEnd(); }
/// <summary>Save the active state.</summary> private void SaveActiveState() { previousActiveState = currentState; }
public override bool Match(IParserState p) { if (p.AtEnd()) return false; int pos = p.GetPos(); if (FirstChild.Match(p)) { p.SetPos(pos); return true; } Debug.Assert(p.GetPos() == pos); return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////// // NON-PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Returns whether the <c>FunctionAccessExpression</c> non-terminal can match. /// </summary> /// <param name="state">A <see cref="IParserState"/> that provides information about the parser's current state.</param> /// <returns> /// <c>true</c> if the <see cref="NonTerminal"/> can match with the current state; otherwise, <c>false</c>. /// </returns> private bool CanMatchFunctionAccessExpression(IParserState state) { return((state.TokenReader.LookAheadToken.Id == SimpleTokenId.Identifier) && (state.TokenReader.GetLookAheadToken(2).Id == SimpleTokenId.OpenParenthesis)); }
public override bool Match(IParserState p) { if (p.AtEnd()) return false; if (p.GetChar() == mData) { p.GotoNext(); return true; } return false; }
private static StreamWriter DescribeState( IReportData data, IParserState state, StreamWriter output, string indent) { foreach (var item in state.DotItems) { output.Write(indent); DescribeItem(data, item, output); output.WriteLine(); } return output; }
public override bool Match(IParserState p) { int pos = p.GetPos(); foreach (char c in mData) { if (p.AtEnd()) { p.SetPos(pos); return false; } if (p.GetChar() != c) { p.SetPos(pos); return false; } p.GotoNext(); } return true; }
public override bool Match(IParserState p) { return(p.AtEnd()); }
public override bool Match(IParserState p) { if (!p.AtEnd()) { p.GotoNext(); return true; } return false; }
public override bool Match(IParserState p) { foreach (Rule r in Children) { if (r.Match(p)) return true; } return false; }
private IParserErrorResult DontReportBeforeClosingBrace(IParserState state) { // Commas are not necessary before the closing brace, so ignore it return(state.TokenReader.LookAheadToken.Id == JsonTokenId.CloseCurlyBrace ? ParserErrorResults.Ignore : ParserErrorResults.Continue); }