Exemplo n.º 1
0
        private static StreamWriter DescribeItem(
            IReportData data,
            IParserDotItem item,
            StreamWriter output,
            bool showLookaheads = true)
        {
            var production = item.Production;

            output.Write(production.Outcome.Name);
            output.Write(" ->");
            int i = 0;

            foreach (var symbol in production.Pattern)
            {
                if (item.Position == i)
                {
                    output.Write(" •");
                }

                output.Write(" ");
                output.Write(symbol.Name);

                ++i;
            }

            if (item.Position == production.PatternTokens.Length)
            {
                output.Write(" •");
            }

            if (showLookaheads)
            {
                output.Write("  |LA = {");
                output.Write(string.Join(", ", (from la in item.LA select data.Grammar.Symbols[la].Name)));
                output.Write("}");
            }

            return(output);
        }
        private static StreamWriter DescribeItem(
            IReportData     data,
            IParserDotItem  item,
            StreamWriter    output,
            bool showLookaheads = true)
        {
            var production = item.Production;
            output.Write(production.Outcome.Name);
            output.Write(" ->");
            int i = 0;
            foreach (var symbol in production.Pattern)
            {
                if (item.Position == i)
                {
                    output.Write(" •");
                }

                output.Write(" ");
                output.Write(symbol.Name);

                ++i;
            }

            if (item.Position == production.PatternTokens.Length)
            {
                output.Write(" •");
            }

            if (showLookaheads)
            {
                output.Write("  |LA = {");
                output.Write(string.Join(", ", (from la in item.LA select data.Grammar.Symbols[la].Name)));
                output.Write("}");
            }

            return output;
        }
Exemplo n.º 3
0
        private void DescribeItem(
            IndentedTextWriter output,
            IParserDotItem item,
            bool showLookaheads = true)
        {
            var prod = item.Production;

            output.Write(prod.Outcome.Name);
            output.Write(" ->");
            for (int i = 0; i != prod.Pattern.Length; ++i)
            {
                if (item.Position == i)
                {
                    output.Write(" .>");
                }

                output.Write(" ");
                output.Write(prod.Pattern[i].Name);
            }

            if (item.Position == prod.Pattern.Length)
            {
                output.Write(" .>");
            }

            if (showLookaheads)
            {
                output.Write("  |LA = {");
                output.Write(
                    string.Join(
                        ", ",
                        from la in item.LA
                        select data.Grammar.Symbols[la].Name));
                output.Write("}");
            }
        }