public void Visit(NodeIf @if) { log.Error(@if.Span, "Expressions are not valid in this placement. Perhaps you meant to put it in a function?"); }
public void Visit(NodeIf @if) { throw new NotImplementedException(); }
public void Visit(NodeIf @if) { @if.conditions.ForEach(cond => { Write("'if' "); cond.condition.Accept(this); WriteLine(" '{' "); Tab(); cond.body.ForEach(node => { WriteTabs(); node.Accept(this); WriteLine(); }); Untab(); WriteLine(); WriteTabs(); Write(" '}' "); }); if (@if.fail.Count > 0) { Write("'el' "); Write(" '{' "); Tab(); @if.fail.ForEach(node => { WriteTabs(); node.Accept(this); WriteLine(); }); Untab(); WriteLine(); WriteTabs(); Write(" '}' "); } }
public void Visit(NodeIf @if) { }
private NodeExpr ParsePrimaryExpr(bool isEnclosed, bool doError = true) { if (!HasCurrent) { log.Error(GetLastSpan(), "Expected a primary expression, got end of file."); return null; } NodeExpr result; switch (Current.type) { case IF: { var @if = new NodeIf(); while (Check(IF)) { Advance(); @if.conditions.Add(new NodeIf.IfBlock(ParseExpr(), ParseBlock())); if (Check(EL)) { if (!Check(IF)) { @if.fail = ParseBlock(); break; } else Advance(); } } result = @if; } break; case LPAREN: var lparen = Current; Advance(); if (Check(RPAREN)) { result = new NodeTuple(lparen, Current, new List<NodeExpr>()); Advance(); break; } bool trailingComma; var exprs = ParseCommaList(out trailingComma); if (exprs.Count == 1 && !trailingComma) { Expect(RPAREN, "Expected ')' to match opening '('."); result = new NodeEnclosed(lparen, Last, exprs[0]); } else { Expect(RPAREN, "Expected ')' to close tuple."); result = new NodeTuple(lparen, Last, exprs); } break; case TRUE: case FALSE: { result = new NodeBool(Current); Advance(); } break; case INT: { result = new NodeInt(Current); Advance(); } break; case STR: { result = new NodeStr(Current); Advance(); } break; case IDENT: { result = new NodeId(Current); Advance(); } break; default: if (doError) { log.Error(GetLastSpan(), "Unexpected token '{0}' when parsing primary expression.", Current); Advance(); } return null; } // TODO(kai): check field index. while (Check(DOT)) { var dot = Current; Advance(); result = new NodeIndex(result, dot, new NodeId(ExpectIdent("Identifier expected for type index."))); } return ParseInvoke(result, isEnclosed); }