public ElaProgram() { TopLevel = new ElaEquationSet(); Includes = new List<ElaModuleInclude>(); }
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); }
//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])); }
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(); } }
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); }
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(); }
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); }
public ElaProgram() { TopLevel = new ElaEquationSet(); Includes = new List <ElaModuleInclude>(); }