Пример #1
0
 public ElaProgram()
 {
     TopLevel = new ElaEquationSet();
     Includes = new List<ElaModuleInclude>();
 }
Пример #2
0
        void DoBlockStmt(ref ElaExpression eqt)
        {
            var cexp1 = default(ElaExpression);
            var cexp2 = default(ElaExpression);

            if (StartOf(4)) {
            EmbExpr(out cexp1);
            if (la.kind == 64) {
                Get();
                EmbExpr(out cexp2);
            }
            ProcessDoBlock(cexp1, cexp2, ref eqt);
            } else if (la.kind == 32) {
            scanner.InjectBlock();
            var eqs = new ElaEquationSet();

            Get();
            Binding(eqs);
            if (eqt.Type == ElaNodeType.LetBinding)
               ((ElaLetBinding)eqt).Equations.Equations.AddRange(eqs.Equations);
            else
            {
                var lt = new ElaLetBinding(t);
                lt.Equations = eqs;
                if (eqt.Type == ElaNodeType.Lambda)
                    ((ElaLambda)eqt).Right = lt;
                else
                    lt.Expression = eqt;
                eqt = lt;
            }

            EndBlock();
            } else SynErr(117);
        }
Пример #3
0
        //Compiles a provided set of equations. This method is to be used for local
        //scopes only.
        private void CompileEquationSet(ElaEquationSet set, LabelMap map)
        {
            var list = RunForwardDeclaration(set.Equations, map);
            list = ProcessFunctions(list, map);
            list = ProcessBindings(list, map);

            //Expressions are not allowed in this context
            if (list.Count > 0)
                for (var i = 0; i < list.Count; i++)
                    AddError(ElaCompilerError.InvalidExpression, list[i], FormatNode(list[i]));
        }
Пример #4
0
        void BindingChain(out ElaEquationSet block)
        {
            block = new ElaEquationSet();
            scanner.InjectBlock();

            Binding(block);
            if (RequireEndBlock())
            EndBlock();
            while (StartOf(3)) {
            scanner.InjectBlock();
            Binding(block);
            if (RequireEndBlock())
            EndBlock();
            }
        }
Пример #5
0
        void Binding(ElaEquationSet block)
        {
            var bid = default(ElaEquation);
            var left = default(ElaExpression);
            var right = default(ElaExpression);

            Expr(out left);
            bid = new ElaEquation(t);
            if (la.kind == 23 || la.kind == 51 || la.kind == 57) {
            if (la.kind == 57) {
                Get();
                Expr(out right);
            } else if (la.kind == 23) {
                Get();
                Guard(out right);
            } else {
                Attribute(ref left);
            }
            }
            if (la.kind == 43) {
            var cb = default(ElaEquationSet);
            WhereBinding(out cb);
            if (left != null && left.Type == ElaNodeType.Header)
               AddError(ElaParserError.InvalidAttributeWhere);

                var letb = new ElaLetBinding();
                   if (cb != null) letb.SetLinePragma(cb.Line, cb.Column);
                   letb.Equations = cb;

                if (right != null)
                {
                    letb.Expression = right;
                       right = letb;
                }
                else
                {
                    letb.Expression = left;
                    left = letb;
                }

            }
            ProcessBinding(block, bid, left, right);
        }
Пример #6
0
        void WhereBinding(out ElaEquationSet block)
        {
            scanner.InjectBlock();
            bindings.Push(null);
            var skip = false;

            while (!(la.kind == 0 || la.kind == 43)) {SynErr(101); Get();}
            Expect(43);
            if (la.kind == 50) {
            EndBlock();
            skip=true;
            }
            BindingChain(out block);
            bindings.Pop();
            if (!skip)
            EndBlock();
        }
Пример #7
0
        private void ProcessBinding(ElaEquationSet block, ElaEquation bid, ElaExpression left, ElaExpression right)
        {
            bid.Left = left;
            bid.Right = right;

            if (bindings.Peek() == unit)
            {
                block.Equations.Add(bid);
                return;
            }

            var fName = default(String);

            if (right != null && left.Type == ElaNodeType.Juxtaposition && !left.Parens)
            {
                var fc = (ElaJuxtaposition)left;

                if (fc.Target.Type == ElaNodeType.NameReference)
                    fName = fc.Target.GetName();
            }

            if (fName != null)
            {
                var lastB = bindings.Peek();

                if (lastB != null && ((ElaJuxtaposition)lastB.Left).Target.GetName() == fName)
                    lastB.Next = bid;
                else
                    block.Equations.Add(bid);

                bindings.Pop();
                bindings.Push(bid);
            }
            else
                block.Equations.Add(bid);
        }
Пример #8
0
 public ElaProgram()
 {
     TopLevel = new ElaEquationSet();
     Includes = new List <ElaModuleInclude>();
 }