public void IsEmpty_WhenTerminalsHasValues_ReturnsExpected(string[] terminals, bool expected)
        {
            // Arrange:
            var ts = new TerminalSet();

            foreach (var terminal in terminals)
            {
                ts.Add(terminal);
            }

            // Act:
            var actual = ts.IsEmpty();

            // Assert:
            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        private bool GetSymbol(TerminalSet followers, bool done, bool genXCPN)
        {
            string s;

              if (symbol.IsProcessed) NextSymbol();
              symbol.SetProcessed(done);
              if (parseAnyText || followers.IsEmpty()) return true;

              if (syntaxErrorStat) return false;
              if (symbol.Terminal == ANYSYM || followers.Contains(symbol.Terminal))
            return true;
              else
              {
            if (terminalAsId && symbol.Terminal != Identifier)
            {
              int t = symbol.Terminal;
              symbol.Terminal = Identifier;
              if (symbol.HasIdFormat && followers.Contains(symbol.Terminal))
              {
            return true;
              }
              symbol.Terminal = t; // restore error value
            }

            switch (symbol.Terminal)
            {
              case EndOfLine:
            if (seeEndOfLine) s = "<EndOfLine>"; else goto default;
            s = "<EndOfLine>";
            break;
              case EndOfInput:
            s = "<EndOfInput>";
            break;
              default:
            s = String.Format("\"{0}\"", symbol.ToString());
            break;
            }
              }
              s = String.Format("*** Unexpected symbol: {0}{1}*** Expected one of: {2}", s,
                         Environment.NewLine, terminalTable.TerminalImageSet(followers));
              if (genXCPN)
            SyntaxError = s;
              else
            errorMessage = s;

              return true;
        }
Beispiel #3
0
            protected override bool GetSymbol(TerminalSet followers, bool done, bool genXCPN)
            {
                string s;

                if (symbol.IsProcessed)
                {
                    NextSymbol();
                }

                symbol.SetProcessed(done);
                if (parseAnyText || followers.IsEmpty())
                {
                    return(true);
                }

                if (syntaxErrorStat)
                {
                    return(false);
                }

                if (symbol.TerminalId == ANYSYM || followers.Contains(symbol.TerminalId))
                {
                    return(true);
                }

                switch (symbol.TerminalId)
                {
                case EndOfLine:
                    if (seeEndOfLine)
                    {
                        s = "<EndOfLine>";
                    }
                    else
                    {
                        goto default;
                    }
                    s = "<EndOfLine>";
                    break;

                case EndOfInput:
                    s = "<EndOfInput>";
                    break;

                default:
                    s = String.Format("\"{0}\"", symbol.ToString());
                    break;
                }

                s = String.Format("*** Unexpected symbol: {0}{1}*** Expected one of: {2}", s,
                                  Environment.NewLine, terminalTable.TerminalImageSet(followers));
                if (genXCPN)
                {
                    SyntaxError = s;
                }
                else
                {
                    errorMessage = s;
                }

                return(true);
            }