Esempio n. 1
0
 public override bool Match(IParserState p)
 {
     while (FirstChild.Match(p))
     {
     }
     return(true);
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 private void DescribeState(IndentedTextWriter message, IParserState state)
 {
     foreach (var item in state.DotItems)
     {
         DescribeItem(message, item);
         message.WriteLine();
     }
 }
Esempio n. 4
0
 public override bool Match(IParserState p)
 {
     if (!p.AtEnd())
     {
         p.GotoNext();
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 public override bool Match(IParserState p)
 {
     foreach (Rule r in Children)
     {
         if (r.Match(p))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 11
0
 public override bool Match(IParserState p)
 {
     if (p.AtEnd())
     {
         return(false);
     }
     if (p.GetChar() >= mFirst && p.GetChar() <= mLast)
     {
         p.GotoNext();
         return(true);
     }
     return(false);
 }
Esempio n. 12
0
 public override bool Match(IParserState p)
 {
     if (p.AtEnd())
     {
         return(false);
     }
     if (p.GetChar() == mData)
     {
         p.GotoNext();
         return(true);
     }
     return(false);
 }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
 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);
 }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        /// <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;
 }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
 public void SetState(IParserState state)
 {
     _shortcodeParser.ParserState = state;
 }
Esempio n. 23
0
 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;
 }
Esempio n. 25
0
 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;
 }
Esempio n. 26
0
 public override bool Match(IParserState p)
 {
     FirstChild.Match(p);
     return true;
 }
Esempio n. 27
0
 public override bool Match(IParserState p)
 {
     if (p.AtEnd()) return false;
     if (p.GetChar() >= mFirst && p.GetChar() <= mLast)
     {
         p.GotoNext();
         return true;
     }
     return false;
 }
Esempio n. 28
0
 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;
 }
Esempio n. 29
0
 public void ChangeState(IParserState state)
 {
     _states.Push(state);
 }
Esempio n. 30
0
        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;
        }
Esempio n. 31
0
 public override bool Match(IParserState p)
 {
     return mDeleg().Match(p);
 }
Esempio n. 32
0
 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;
 }
Esempio n. 33
0
 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);
 }
Esempio n. 34
0
 public override bool Match(IParserState p)
 {
     while (FirstChild.Match(p))
     { }
     return true;
 }
Esempio n. 35
0
 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;
 }
Esempio n. 36
0
 public override bool Match(IParserState p)
 {
     if (!FirstChild.Match(p))
         return false;
     while (FirstChild.Match(p))
     { }
     return true;
 }
Esempio n. 37
0
 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;
 }
Esempio n. 38
0
 /// <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);
Esempio n. 39
0
 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;
 }
Esempio n. 40
0
 public override bool Match(IParserState p)
 {
     return p.AtEnd();
 }
 /// <summary>Save the active state.</summary>
 private void SaveActiveState()
 {
     previousActiveState = currentState;
 }
Esempio n. 42
0
 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;
 }
Esempio n. 43
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // 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));
        }
Esempio n. 44
0
 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;
        }
Esempio n. 46
0
        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;
        }
Esempio n. 47
0
 public override bool Match(IParserState p)
 {
     return(p.AtEnd());
 }
Esempio n. 48
0
 public override bool Match(IParserState p)
 {
     if (!p.AtEnd())
     {
         p.GotoNext();
         return true;
     }
     return false;
 }
Esempio n. 49
0
 public override bool Match(IParserState p)
 {
     foreach (Rule r in Children)
     {
         if (r.Match(p))
             return true;
     }
     return false;
 }
Esempio n. 50
0
 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);
 }