Exemplo n.º 1
0
        private TerminalToken GetLookahead()
        {
            if (lookahead != null)
            {
                return(lookahead);
            }
            do
            {
                TerminalToken token = tokenizer.RetrieveToken();
                if (token.Symbol is SymbolCommentLine)
                {
                    if (!ProcessCommentLine(token))
                    {
                        continueParsing = false;
                    }
                }
                else if (token.Symbol is SymbolCommentStart)
                {
                    if (!ProcessCommentStart(token))
                    {
                        continueParsing = false;
                    }
                }
                else if (token.Symbol is SymbolWhiteSpace)
                {
                    if (!ProcessWhiteSpace(token))
                    {
                        continueParsing = false;
                    }
                }
                else if (token.Symbol is SymbolError)
                {
                    if (!ProcessError(token))
                    {
                        continueParsing = false;
                    }
                }
                else
                {
                    lookahead = token;
                }
                if (!continueParsing)
                {
                    break;
                }
            } while (lookahead == null);

            if ((lookahead != null) && (OnTokenRead != null))
            {
                TokenReadEventArgs args = new TokenReadEventArgs(lookahead);
                OnTokenRead(this, args);
                if (args.Continue == false)
                {
                    continueParsing = false;
                    lookahead       = null;
                }
            }
            return(lookahead);
        }
Exemplo n.º 2
0
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
 {
     try
     {
         args.Token.UserObject = CreateObject(args.Token);
     }
     catch (Exception e)
     {
         args.Continue = false;
         //todo: Report message to UI?
     }
 }
Exemplo n.º 3
0
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
 {
     try
     {
         args.Token.UserObject = CreateObject(args.Token);
     }
     catch (Exception e)
     {
         args.Continue = false;
         MainForm.mainForm.WriteResult(e.Message);
     }
 }
Exemplo n.º 4
0
        private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
        {
            args.Token.UserObject = CreateObject(args.Token);

            int tmp = args.Token.Symbol.Id;

            string lexem = args.Token.ToString();
            string token = ((SymbolConstants)args.Token.Symbol.Id).ToString().Substring(7);

            //string token = args.Token.Symbol.Name.ToString();
            dt.Rows.Add(lexem, token);
        }
Exemplo n.º 5
0
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
 {
     try
     {
         args.Token.UserObject = CreateObject(args.Token);
     }
     catch (Exception e)
     {
         _mainForm.setLeituraState(false);
         _mainForm.setSyntaxState(false);
         MessageBox.Show(e.ToString());
         args.Continue = false;
         //todo: Report message to UI?
     }
 }
Exemplo n.º 6
0
        private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
        {
            SymbolConstants symb;

            for (symb = 0; (int)symb < 68; symb++)
            {
                if ((int)symb == args.Token.Symbol.Id && (int)symb != 0)
                {
                    ListViewItem lst = new ListViewItem();
                    lst.SubItems.Add(args.Token.Text);
                    lst.SubItems.Add(symb.ToString());
                    lstlex.Items.Add(lst);
                    break;
                }
            }
        }
Exemplo n.º 7
0
		private TerminalToken GetLookahead()
		{
			if (lookahead != null)
			{
				return lookahead;
			}
			do
			{
				TerminalToken token = tokenizer.RetrieveToken();
				if (token.Symbol is SymbolCommentLine)
				{
					if (!ProcessCommentLine(token))
						continueParsing = false;
				}
				else if (token.Symbol is SymbolCommentStart)
				{
					if (!ProcessCommenStart(token))
						continueParsing = false;
				}
				else if (token.Symbol is SymbolWhiteSpace)
				{
					if (!ProcessWhiteSpace(token))
						continueParsing = false;
				}
				else if (token.Symbol is SymbolError)
				{
					if (!ProcessError(token))
						continueParsing = false;
				}
				else
				{
					lookahead = token;
				}
				if (!continueParsing)
					break;
			} while (lookahead == null);

			if ((lookahead != null) && (OnTokenRead != null))
			{
				TokenReadEventArgs args = new TokenReadEventArgs(lookahead);
				OnTokenRead(this, args);
				if (args.Continue == false)
				{
					continueParsing = false;
					lookahead = null;
				}
			}
			return lookahead;
		}
Exemplo n.º 8
0
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
 {
     try
     {
         args.Token.UserObject = CreateObject(args.Token);
     }
     catch (Exception e)
     {
         args.Continue = false;
         Console.WriteLine(args.Token.ToString());
         //todo: Report message to UI?
     }
 }
Exemplo n.º 9
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.º 10
0
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs Args)
 {
     Args.Token.UserObject = CreateObject(Args.Token);
     Label1.Text          += Args.Token.Text + " ==> " + ((SymbolConstants)Args.Token.Symbol.Id) + "\n";
 }
Exemplo n.º 11
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);
 }
Exemplo n.º 12
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));
            }
        }
Exemplo n.º 13
0
 private void OnTokenRead(LALRParser argParser, TokenReadEventArgs args)
 {
     if (endSymbol == 2)
     {
         TerminalToken eofToken =
             new TerminalToken(SymbolCollection.EOF, SymbolCollection.EOF.Name, args.Token.Location);
         argParser.lookahead = eofToken;
         endSymbol = 3;
         return;
     }
     args.Token.UserObject = CreateObject(args.Token, argParser);
 }
Exemplo n.º 14
0
 private void TokenReadEvent(LALRParser parser, TokenReadEventArgs args)
 {
     try
     {
         args.Token.UserObject = CreateObject(args.Token);
     }
     catch (Exception e)
     {
         args.Continue = false;
         MainForm.mainForm.WriteResult(e.Message);
     }
 }