예제 #1
0
        /// <summary>
        /// Get the array of expected symbols on the given symbol current parser state.
        /// </summary>
        /// <param name="parser">The parser</param>
        /// <param name="curToken">The Symbol</param>
        /// <returns>The array of expected symbols</returns>
        protected internal static List <string> ExpectedSymbols(lr_parser parser, StackList <Symbol> stack, Symbol curToken)
        {
            var actionTab = parser.action_table();
            int state     = ((Symbol)stack.Peek()).parse_state;

            short[]       row      = actionTab[state];
            List <string> expected = new List <string>();

            for (int probe = 0; probe < row.Length; probe++)
            {
                int tag = row[probe++];
                if (tag != -1 && tag != parser.error_sym())
                {//symbol tag different of the default symbol.
                    string name = CobolWordsTokenizer.CupTokenToString(tag);
                    if (name != null)
                    {
                        expected.Add(name);
                    }
                }
            }
            return(expected);
        }
        /// <summary>
        /// Get the array of expected symbols on the given symbol current parser state.
        /// </summary>
        /// <param name="parser">The parser</param>
        /// <param name="curToken">The Symbol</param>
        /// <returns>The array of expected symbols</returns>
        private static List <string> ExpectedSymbols(lr_parser parser, Symbol curToken)
        {
            var actionTab = parser.action_table();
            int state     = ((TypeCobolProgramParser)parser).getParserState();

            short[]       row      = actionTab[state];
            List <string> expected = new List <string>();

            for (int probe = 0; probe < row.Length; probe++)
            {
                int tag = row[probe++];
                if (tag != -1 && tag != parser.error_sym())
                {//symbol tag different of the default symbol.
                    string name = CodeElementTokenizer.CupTokenToString(tag);
                    if (name != null)
                    {
                        expected.Add(name);
                    }
                }
            }
            return(expected);
        }