Beispiel #1
0
        public override void AddImproptuDeclaration(ImproptuDeclContext context)
        {
            var baseName = Name;

            if (context.HasSymbol(baseName))
            {
                return;
            }

            var definitions = new ProdDefList(
                new ProdDef(new ProductionExprList(expr)))
            {
                new ProdDef()
            };

            var production = new Production(
                new Identifier(this, baseName),
                null,
                definitions);

            context.Add(production);
        }
Beispiel #2
0
        public override void AddImproptuDeclaration(ImproptuDeclContext context)
        {
            var baseName = Name;

            if (context.HasSymbol(baseName))
            {
                return;
            }

            if (!context.TryFindType(expr.Name, out var exprType))
            {
                exprType = "Object";
            }

            var actionType = new Identifier(exprType + "List");

            var definitions = new ProdDefList(
                new ProdDef(
                    new ProductionExprList(),
                    new ActionNewExpr(actionType,
                                      new ActionArgs())),
                new ProdDef(
                    new ProductionExprList(
                        new SymbolProdExpr(this, baseName),
                        expr),
                    new ActionFuncExpr(
                        actionType,
                        new ActionArgs(new ActionArg(0), new ActionArg(1)))));

            var production = new Production(
                new Identifier(this, baseName),
                null,
                definitions);

            context.Add(production);
        }