GetExpectedTermSet() public method

public GetExpectedTermSet ( ) : StringSet
return StringSet
示例#1
0
文件: Grammar.cs 项目: wanglong/irony
        // Override this method to perform custom error processing
        public virtual void ReportParseError(ParsingContext context)
        {
            string error = null;

            if (context.CurrentParserInput.Term == this.SyntaxError)
            {
                error = context.CurrentParserInput.Token.Value as string; //scanner error
            }
            else if (context.CurrentParserInput.Term == this.Indent)
            {
                error = Resources.ErrUnexpIndent;
            }
            else if (context.CurrentParserInput.Term == this.Eof && context.OpenBraces.Count > 0)
            {
                if (context.OpenBraces.Count > 0)
                {
                    //report unclosed braces/parenthesis
                    var openBrace = context.OpenBraces.Peek();
                    error = string.Format(Resources.ErrNoClosingBrace, openBrace.Text);
                }
                else
                {
                    error = Resources.ErrUnexpEof;
                }
            }
            else
            {
                var expectedTerms = context.GetExpectedTermSet();
                error = ConstructParserErrorMessage(context, expectedTerms);
            }
            context.AddParserError(error);
        }//method
示例#2
0
 // Override this method to perform custom error processing
 public virtual void ReportParseError(ParsingContext context)
 {
     string error = null;
     if (context.CurrentParserInput.Term == this.SyntaxError)
     error = context.CurrentParserInput.Token.Value as string; //scanner error
     else if (context.CurrentParserInput.Term == this.Indent)
     error = Resources.ErrUnexpIndent;
     else if (context.CurrentParserInput.Term == this.Eof && context.OpenBraces.Count > 0) {
       if (context.OpenBraces.Count > 0) {
     //report unclosed braces/parenthesis
     var openBrace = context.OpenBraces.Peek();
     error = string.Format(Resources.ErrNoClosingBrace, openBrace.Text);
       } else
       error = Resources.ErrUnexpEof;
     }else {
     var expectedTerms = context.GetExpectedTermSet();
     error = ConstructParserErrorMessage(context, expectedTerms);
     }
     context.AddParserError(error);
 }