예제 #1
0
        private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
        {
            string message = "Parse error caused by token: ' " + args.UnexpectedToken.ToString() + " ' " + " in line : " + args.UnexpectedToken.Location.LineNr;

            //todo: Report message to UI?
            lstError.Items.Add(message);
            string message2 = "excepted token: '" + args.ExpectedTokens.ToString() + "'";

            lstError.Items.Add(message2);
        }
예제 #2
0
 private void FireParseError(TerminalToken token)
 {
     if (OnParseError != null)
     {
         ParseErrorEventArgs e = new ParseErrorEventArgs(token, FindExpectedTokens());
         OnParseError(this, e);
         continueParsing = e.Continue != ContinueMode.Stop;
         lookahead       = e.NextToken;
         if ((e.NextToken != null) && (e.Continue == ContinueMode.Insert))
         {
             tokenizer.SetCurrentLocation(token.Location);
         }
     }
 }
예제 #3
0
        private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
        {
            string ExpectedTokens = "Expected Token : '" + args.ExpectedTokens.ToString() + "'";

            errors.Items.Add(ExpectedTokens);

            string UnexpectedToken = "Wrong Token : '" + args.UnexpectedToken.ToString() + "'";

            errors.Items.Add(UnexpectedToken);

            string errorLine = "Error Near By Line : " + args.UnexpectedToken.Location.LineNr;

            errors.Items.Add(errorLine);
            //todo: Report message to UI?
        }
예제 #4
0
        private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
        {
            /*** MODIFICAÇÕES ***/
            String file_name         = _mainForm.getFileName();
            String error_type        = "Syntax error";
            String line_number       = args.UnexpectedToken.Location.LineNr.ToString();
            String col_number        = args.UnexpectedToken.Location.ColumnNr.ToString();
            String error_description = "Error at .. " + args.UnexpectedToken.ToString();

            String unexpectedToken = args.UnexpectedToken.ToString();
            String expectedTokens  = args.ExpectedTokens.ToString();

            String[] aExpectedTokens = expectedTokens.Split(' ');
            String   nextToken       = aExpectedTokens[0];

            int token_id = 0;

            foreach (SymbolConstants symbol in (Enum.GetValues(typeof(SymbolConstants))))
            {
                String symbol_token = symbol.ToString()
                                      .Replace("SYMBOL_", "")
                                      .ToLower();

                if (symbol_token == nextToken)
                {
                    token_id = (int)symbol;
                    break;
                }
            }

            _insertError(file_name, error_type, line_number, col_number, error_description);

            Location location = new Location(0, 0, 0);

            args.NextToken = new TerminalToken(new SymbolTerminal(token_id, nextToken), "", location);
            args.Continue  = ContinueMode.Insert;
            /*** MODIFICAÇÕES ***/
        }
예제 #5
0
 private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
 {
     string message = "Parse error caused by token: '" + args.UnexpectedToken.ToString() + "'";
     //todo: Report message to UI?
 }
예제 #6
0
 private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
 {
     MainForm.mainForm.ShowInputError(args.UnexpectedToken);
     MainForm.mainForm.WriteResult("Parse error caused by token: '" + args.UnexpectedToken.ToString() + "'");
 }
예제 #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="arg">Parse Error Event Aruguments</param>
 public ParseException(ParseErrorEventArgs arg)
     : base(SharedStrings.WARNING_COMMAND_SYNTAX_ERROR + "\r\r" + SharedStrings.UNEXPECTED_TOKEN, arg.UnexpectedToken.Text)
 {
     args = arg;
 }
예제 #8
0
파일: V20Parser.cs 프로젝트: ufjl0683/sshmc
 private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
 {
     string message = "Parse error caused by token: '"+args.UnexpectedToken.ToString()+"'";
     //todo: Report message to UI?
 }
예제 #9
0
 private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
 {
     throw new ParseException(args);
 }
예제 #10
0
 private void FireParseError(TerminalToken token)
 {
     if (OnParseError != null)
     {
         ParseErrorEventArgs e =
             new ParseErrorEventArgs(token, FindExpectedTokens());
         OnParseError(this, e);
         continueParsing = e.Continue != ContinueMode.Stop;
         lookahead = e.NextToken;
         if ((e.NextToken != null) && (e.Continue == ContinueMode.Insert))
             tokenizer.SetCurrentLocation(token.Location);
     }
 }
예제 #11
0
 private void lalrParser_OnParseError(LALRParser parser, ParseErrorEventArgs e)
 {
     // Ignore global parse errors
     OnParseComplete(EventArgs.Empty);
 }
예제 #12
0
        protected virtual void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
        {
			string message = String.Format("Parse error caused by token: '{0}' at location {1}", args.UnexpectedToken, args.UnexpectedToken.Location);
			throw new ParserException(message);
        }
예제 #13
0
 private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
 {
     message = message + "Parse error caused by token: " + args.UnexpectedToken.ToString() + "\n" + "in line : " + args.UnexpectedToken.Location.LineNr + "\n";
     //todo: Report message to UI?
     message = message + "expected token : " + args.ExpectedTokens.ToString() + "\n";
 }
예제 #14
0
        private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
        {
            AddViewItem("Parse error", null, "Expecting the following tokens:",
                args.ExpectedTokens.ToString(),"",5);
            errors++;

            if (errors <= maxerrors)
            {
                args.Continue = ContinueMode.Skip;
                // example for inserting a new token
                /*
                args.Continue = ContinueMode.Insert;
                TerminalToken token = new TerminalToken((SymbolTerminal)parser.Symbols.Get(4),
                                                        "555",
                                                        new Location(0, 0, 0));
                args.NextToken = token;
                */
            }
        }
예제 #15
0
        private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
        {
            Context.ExpectedTokens = args.ExpectedTokens.ToString();
            if(args.NextToken!=null)
            Context.NextToken = args.NextToken.ToString();
            if (args.UnexpectedToken != null)
            Context.UnexpectedToken = args.UnexpectedToken.ToString();

            throw new ParseException(args);
        }
예제 #16
0
 private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
 {
     MainForm.mainForm.ShowInputError(args.UnexpectedToken);
     MainForm.mainForm.WriteResult("Parse error caused by token: '"+args.UnexpectedToken.ToString()+"'");
 }
예제 #17
0
		private void FireParseError(TerminalToken token)
		{
			if (OnParseError != null)
			{
				ParseErrorEventArgs e = 
					new ParseErrorEventArgs(token, FindExpectedTokens());
				OnParseError(this, e);
				continueParsing = e.Continue;
				lookahead = e.NextToken;
			}
		}
예제 #18
0
파일: Protocol.cs 프로젝트: ufjl0683/sshmc
 private void parser_OnParseError(LALRParser parser, ParseErrorEventArgs args)
 {
     string message;
        message=args.UnexpectedToken.Location+",unexpect token:"+args.UnexpectedToken.Text;
        throw new Exception(message);
 }
예제 #19
0
        private void ParseErrorEvent(LALRParser parser, ParseErrorEventArgs args)
        {   
            
			string message = args.UnexpectedToken.Location.ToString()+"[\n\r"; 
			message+="Unexpected Token: '"+args.UnexpectedToken.ToString()+"'\n\rExpected: '"+args.ExpectedTokens.ToString()+"'";
            if (LastGotoEventArgs!=null) message+="\n\rLastGoto:"+LastGotoEventArgs.Symbol.ToString();
			if (LastReduceEventArgs!=null) message+="\n\rLastReduce.Rule:"+LastReduceEventArgs.Rule.ToString();			
			message+="\n\r]";
			Console.WriteLine(message);
        }                
예제 #20
0
 private void ParseErrorEvent(LALRParser argParser, ParseErrorEventArgs args)
 {
     WriteError("Parse error caused by token: '" + args.UnexpectedToken + "'" + " at " +
                args.UnexpectedToken.Location, args.UnexpectedToken.Location);
     args.Continue = ContinueMode.Insert;
 }