Пример #1
0
        public PostTokenList Parse()
        {
            var   res  = new PostTokenList();
            Token last = null;
            bool  know = false;

            for (var i = 0; i < tokens.Count(); i++)
            {
                Token token = tokens[i];
                if (token.type != Token.Type.KEYWORD)
                {
                    if (res.LastFinished(last, know) && !token.CannotOpenWith() && (res.Count == 0 || res.Last.Keyname != "expression"))
                    {
                        res.Add(new PostToken("expression"));
                    }
                    res.Last.AddData(token.value);
                }
                else
                {
                    res.Add(new PostToken(token.value));
                }
                last = token;
                know = true;
            }
            return(res);
        }
Пример #2
0
    /// <summary>Create a new Parser instance and immediately consume the given <paramref name="aData"/>
    /// string. On return the <seealso cref="Tokens"/> property is available for enumeration.</summary>
    /// <param name="aData">The text to be parsed. WARNING : This is expected to be a single full line
    /// of text. The parser can be create with a special "pattern recognition" mode.</param>
    /// <param name="aIncludeWhiteSpace"></param>
    /// <param name="aAllowPatterns">True if <paramref name="aData"/> is a pattern and thus the parsing
    /// should be performed specifically.</param>
    /// <exception cref="Exception">At least one unrecognized token has been parsed.</exception>
    public Parser(string aData, int lineNumber, bool aIncludeWhiteSpace, bool aAllowPatterns) {
      mData = aData;
      mIncludeWhiteSpace = aIncludeWhiteSpace;
      mAllowPatterns = aAllowPatterns;
      mAllWhitespace = true;

      mTokens = Parse(lineNumber);
      if (mTokens.Count(q => q.Type == TokenType.Unknown) > 0) {

        foreach(Token token in mTokens)
        {
          if (TokenType.Unknown == token.Type) {
            throw new Exception(string.Format("Unknown token '{0}' found at {1}/{2}.",
              token.RawValue ?? "NULL", token.LineNumber, token.SrcPosStart));
          }
        }
      }
    }
Пример #3
0
 public static int AcctualUserCount()
 {
     return(TokenList.Count());
     //return CleanerIsRunning ? 1 : 0;
 }
 public static int AcctualUserCount() => _tokenList.Count();