Пример #1
0
 public CanonicalRepresentation(ParseTableBuilder builder)
 {
     mTableBuilder = builder;
     mId2String    = builder.GetStringRepresentationForAllStates();
     mPrintId2Id   = Enumerable.Range(1, builder.mId2States.Count - 1).ToArray();
     Array.Sort(mPrintId2Id, (lhs, rhs) =>
                string.Compare(mId2String[lhs], mId2String[rhs], StringComparison.Ordinal));
     mPrintId2Id = new[] { 0 }.Concat(mPrintId2Id).ToArray();
     mId2PrintId = InverseMap(mPrintId2Id);
 }
Пример #2
0
        public void BuildTable()
        {
            var cfg = CfgBuilderGenerator
                      .Generate()
                      .Build();

            var tableBuilder = new ParseTableBuilder(true);

            tableBuilder.BuildTableForCfg(cfg);
            Approvals.Verify(tableBuilder.Dump());
        }
Пример #3
0
        public void DumpParseTable()
        {
            var builder = new ParseTableBuilder(true);

            builder.BuildTableForCfg(new CfgBuilder()
                                     .AddAllProductionsInClass <Expr>()
                                     .DeclarePrecedence(Symbol.Of <OpAdd>(), Symbol.Of <Symbols.OpMinus>())
                                     .DeclarePrecedence(Symbol.Of <Symbols.OpMult>(), Symbol.Of <Symbols.OpDiv>())
                                     .DeclarePrecedence(Symbol.Of <Symbols.OpExp>())
                                     .DeclarePrecedence(Symbol.Of <Symbols.OpUnaryMinus>())
                                     .Build());
            Approvals.Verify(builder.Dump());
        }