Purpose of method IsInMultiMatchSet(int,IToken)

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Civa
Avatar
Hi all,

While writing common DescentSemanticParser today I came up with strange and confusing thing.I can not determine whats real purpose of method IsInMultiMatchSet and how to use it?

I realized it is really important method because I couldn't avoid some syntax error because of its return value.Namely I have added couple of custom TokenID's and i suppose there should be as much elements in each of 2-dimensional arrays (property MultiMatchSets)
as constants where TokenIDs are defined.Am I right?

So how is it working ?How can I know where to put Y/n in this 2-dimensional array?

here is my custom token ID enum :

/// <summary>
        /// The Invalid token ID.
        /// </summary>
        public const int Invalid = 0;

        /// <summary>
        /// The DocumentEnd token ID.
        /// </summary>
        public const int DocumentEnd = 1;

        /// <summary>
        /// The LanguageTransitionStart token ID.
        /// </summary>
        public const int LanguageTransitionStart = 2;

        /// <summary>
        /// The LanguageTransitionEnd token ID.
        /// </summary>
        public const int LanguageTransitionEnd = 3;

        /// <summary>
        /// The Whitespace token ID.
        /// </summary>
        public const int Whitespace = 4;

        ///<summary>
        ///The Dot Token ID.
        ///</summary>
        public const int Dot = 5;

        /// <summary>
        /// The LineTerminator token ID.
        /// </summary>
        public const int LineTerminator = 6;

        /// <summary>
        /// The SingleLineComment token ID.
        /// </summary>
        public const int SingleLineComment = 7;

        /// <summary>
        /// The MultiLineComment token ID.
        /// </summary>
        public const int MultiLineComment = 8;

        /// <summary>
        /// The Number token ID.
        /// </summary>
        public const int Number = 9;

        /// <summary>
        /// The Identifier token ID.
        /// </summary>
        public const int Identifier = 10;

        /// <summary>
        /// The KeywordStart token ID.
        /// </summary>
        public const int KeywordStart = 11;

        /// <summary>
        /// The Function token ID.
        /// </summary>
        public const int Sub = 12;

        /// <summary>
        /// The Dim token ID.
        /// </summary>
        public const int Dim = 13;

        /// <summary>
        /// The Return token ID.
        /// </summary>
        public const int Return = 14;

        /// <summary>
        /// The As token ID.
        /// </summary>
        public const int As = 15;

        /// <summary>
        /// The KeywordEnd token ID.
        /// </summary>
        public const int KeywordEnd = 16;

        /// <summary>
        /// The OperatorOrPunctuatorStart token ID.
        /// </summary>
        public const int OperatorOrPunctuatorStart = 17;

        /// <summary>
        /// The OpenCurlyBrace token ID.
        /// </summary>
        public const int OpenCurlyBrace = 18;

        /// <summary>
        /// The CloseCurlyBrace token ID.
        /// </summary>
        public const int CloseCurlyBrace = 19;

        /// <summary>
        /// The OpenParenthesis token ID.
        /// </summary>
        public const int OpenParenthesis = 20;

        /// <summary>
        /// The CloseParenthesis token ID.
        /// </summary>
        public const int CloseParenthesis = 21;

        /// <summary>
        /// The DataType token ID.
        /// </summary>
        public const int DataType = 22;
        /// <summary>
        /// The Comma token ID.
        /// </summary>
        public const int Comma = 23;

        /// <summary>
        /// The SemiColon token ID.
        /// </summary>
        public const int SemiColon = 24;

        /// <summary>
        /// The Addition token ID.
        /// </summary>
        public const int Addition = 25;

        /// <summary>
        /// The Subtraction token ID.
        /// </summary>
        public const int Subtraction = 26;

        /// <summary>
        /// The Multiplication token ID.
        /// </summary>
        public const int Multiplication = 27;

        /// <summary>
        /// The Division token ID.
        /// </summary>
        public const int Division = 28;

        /// <summary>
        /// The Assignment token ID.
        /// </summary>
        public const int Assignment = 29;

        /// <summary>
        /// The Equality token ID.
        /// </summary>
        public const int Equality = 30;

        /// <summary>
        /// The Inequality token ID.
        /// </summary>
        public const int Inequality = 31;

        /// <summary>
        /// The OperatorOrPunctuatorEnd token ID.
        /// </summary>
        public const int OperatorOrPunctuatorEnd = 32;

        /// <summary>
        /// The MaxTokenID token ID.
        /// </summary>
        public const int MaxTokenID = 33;
And here is MultiMatchSets property defined in my custom DescentSemanticParser :

private static bool[,] multiMatchSets = 
        {
            // 0: Identifier SemiColon Dim Return OpenCurlyBrace
 
            {
             n,//0-The Invalid token ID.
             n,//1-The DocumentEnd token ID.
             n,//2-The LanguageTransitionStart token ID.
             n,//3-The LanguageTransitionEnd token ID.
             n,//4-The Whitespace token ID.
             n,//5-The Dot Token ID.
             n,//6-The LineTerminator token ID.
             n,//7-The SingleLineComment token ID.
             n,//8-The MultiLineComment token ID.
             n,//9-The Number token ID.
             Y,//10-The Identifier token ID.
             n,//11-The KeywordStart token ID.
             n,//12-The Function token ID.
             Y,//13-The Dim token ID.
             Y,//14-The Return token ID.
             n,//15-The As token ID.
             n,//16-The KeywordEnd token ID.
             n,//17-The OperatorOrPunctuatorStart token ID.
             Y,//18-The OpenCurlyBrace token ID.
             n,//19-The CloseCurlyBrace token ID.
             n,//20-The OpenParenthesis token ID.
             n,//21-The CloseParenthesis token ID.
             n,//22-The DataType token ID.
             n,//23-The Comma token ID.
             Y,//24-The SemiColon token ID.
             n,//25-The Addition token ID.
             n,//26-The Subtraction token ID.
             n,//27-The Multiplication token ID.
             n,//28-The Division token ID.
             n,//29-The Assignment token ID.
             n,//30-The Equality token ID.
             n,//31-The Inequality token ID.
             n,//32-The OperatorOrPunctuatorEnd token ID.
             n //33-The MaxTokenID token ID.
            },
            // 1: Identifier SemiColon Dim Return OpenCurlyBrace 

            {
             n,//0-The Invalid token ID.
             n,//1-The DocumentEnd token ID.
             n,//2-The LanguageTransitionStart token ID.
             n,//3-The LanguageTransitionEnd token ID.
             n,//4-The Whitespace token ID.
             n,//5-The Dot Token ID.
             n,//6-The LineTerminator token ID.
             n,//7-The SingleLineComment token ID.
             n,//8-The MultiLineComment token ID.
             n,//9-The Number token ID.
             Y,//10-The Identifier token ID.
             n,//11-The KeywordStart token ID.
             n,//12-The Function token ID.
             Y,//13-The Dim token ID.
             Y,//14-The Return token ID.
             n,//15-The As token ID.
             n,//16-The KeywordEnd token ID.
             n,//17-The OperatorOrPunctuatorStart token ID.
             Y,//18-The OpenCurlyBrace token ID.
             n,//19-The CloseCurlyBrace token ID.
             n,//20-The OpenParenthesis token ID.
             n,//21-The CloseParenthesis token ID.
             n,//22-The DataType token ID.
             n,//23-The Comma token ID.
             Y,//24-The SemiColon token ID.
             n,//25-The Addition token ID.
             n,//26-The Subtraction token ID.
             n,//27-The Multiplication token ID.
             n,//28-The Division token ID.
             n,//29-The Assignment token ID.
             n,//30-The Equality token ID.
             n,//31-The Inequality token ID.
             n,//32-The OperatorOrPunctuatorEnd token ID.
             n //33-The MaxTokenID token ID.
            }
        };
If you demystify me this one it would be greatly appreciated. :)

Thank you.

Best regards,

Civa

Comments (3)

Posted 15 years ago by Civa
Avatar
I apologize for my previous post.It's not about DescentSemanticParser as I mentioned it is just SemanticParser.Little bit of confusion could occur over here :)
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Civa,

I will reply to your other lengthy post later however I wanted to stop you on this one before you put much work into it. The SemanticParser classes are NOT supposed to be edited manually by you, as it appears you are doing in this post.

Rather, you should be building a grammar file that is loaded in the Grammar Designer. Then you use the Grammar Designer to generate the code for the semantic parser. The generation process will handle all the multi-match set building code, etc. for you.


Actipro Software Support

Posted 15 years ago by Civa
Avatar
Ok thank you very much.
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.