Exemplo n.º 1
0
 /// <summary>
 /// Event handler for the action of reading a token.
 /// </summary>
 /// <param name="parser">parser that is the source of this event</param>
 /// <param name="args">event arguments</param>
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
 {
     AddViewItem("Token Read",
                 args.Token.Location,
                 args.Token.Symbol.ToString(),
                 StringUtil.ShowEscapeChars(args.Token.Text), "", 0);
 }
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
 {
     try
     {
         args.Token.UserObject = CreateObject(args.Token);
     }
     catch (ApplicationException ex)
     {
         args.Continue = false;
         tokenStack.Clear();
         Logger.Log(DateTime.Now + ":  " + ex.Message);
         throw ex;
     }
 }
Exemplo n.º 3
0
        public void OnRead(LALRParser parser, TokenReadEventArgs args)
        {
            current          = new CLL_token();
            current.location = args.Token.Location;

            switch (args.Token.Symbol.Name)
            {
            case "class id":
                current.type = Token_Type.id;
                break;
            }

            current.text = args.Token.Text;
        }
Exemplo n.º 4
0
        void _Parser_OnTokenRead(LALRParser parser, TokenReadEventArgs args)
        {
            var token = args.Token;
            Func <Parser, TerminalToken, object> handler;

            if (Internal.SymbolRules.Handlers.TryGetValue((SymbolConstants)token.Symbol.Id, out handler))
            {
                try
                {
                    token.UserObject = handler(this, token);
                }
                catch (Exception ex)
                {
                    Errors.Add(string.Format("{0}: {1}", args.Token.Symbol, ex.Message));
                    args.Continue = false;
                }
            }
        }
Exemplo n.º 5
0
        private void lalrParser_OnTokenRead(LALRParser parser, TokenReadEventArgs e)
        {
            // Pass these names to the WIQLBuilder. It can translate them using its own lookup table
            // in to the appropriate field name.

            // Huge switch statement for each token type. Originally this was going to be transformed
            // into a type per symbol, however leaving the WiqlBuilder to deal with it seems a lot simpler.
            switch (e.Token.Symbol.Name)
            {
            //
            // Matched field identifiers
            //
            case "Project":
                _comparisonType = FieldComparison.Project;
                _fieldName      = e.Token.Symbol.Name;
                break;

            case "CreatedBy":
            case "AssignedTo":
            case "ResolvedBy":
                _comparisonType = FieldComparison.User;
                _fieldName      = e.Token.Symbol.Name;
                break;

            case "CreatedOn":
            case "ResolvedOn":
                _comparisonType = FieldComparison.Date;
                _fieldName      = e.Token.Symbol.Name;
                break;

            case "Description":
                _comparisonType = FieldComparison.Contains;
                _fieldName      = e.Token.Symbol.Name;
                break;

            case "State":
            case "Type":
            case "Area":
            case "Iteration":
                _comparisonType = FieldComparison.ExactMatch;
                _fieldName      = e.Token.Symbol.Name;
                break;

            //
            // OR/NOT
            //
            case "Or":
                _fieldName = "";
                _wiqlBuilder.Or();
                break;

            case "Negate":
                _wiqlBuilder.Not();
                break;

            //
            // Strings
            //
            case "StringLiteral":

                // Make sure contains is kept for literals - mainly so the description field works.
                if (_comparisonType == FieldComparison.Contains)
                {
                    _wiqlBuilder.AppendField(_fieldName, e.Token.Text.Replace("\"", ""), FieldComparison.Contains);
                }
                else
                {
                    _wiqlBuilder.AppendField(_fieldName, e.Token.Text.Replace("\"", ""), FieldComparison.ExactMatch);
                }

                _fieldName      = "";
                _comparisonType = FieldComparison.Contains;
                break;

            case "AnyChar":
                _wiqlBuilder.AppendField(_fieldName, e.Token.Text, _comparisonType);
                _fieldName      = "";
                _comparisonType = FieldComparison.Contains;
                break;

            // End of parsing
            case "(EOF)":
                OnParseComplete(EventArgs.Empty);
                break;

            default:
                // Exception?
                throw new NotImplementedException(string.Format("{0} is not supported", e.Token.Symbol.Name));
            }
        }