public void Visit(NodeInt i) { throw new NotImplementedException(); }
public void Visit(NodeInt i) { log.Error(i.Span, "An int literal is not valid in this placement. Perhaps you meant to put it in a function?"); }
public void Visit(NodeInt i) { var token = i.Token; var suffix = token.NumericSuffix; TyRef ty; switch (suffix) { case "i8": ty = TyInt.Int8Ty; break; case "i16": ty = TyInt.Int16Ty; break; case "": case "i32": ty = TyInt.Int32Ty; break; case "i64": ty = TyInt.Int64Ty; break; case "u8": ty = TyUint.Uint8Ty; break; case "u16": ty = TyUint.Uint16Ty; break; case "u32": ty = TyUint.Uint32Ty; break; case "u64": ty = TyUint.Uint64Ty; break; default: ty = TyInt.Int32Ty; log.Error(i.Span, "Invalid integer suffix \"{0}\"!", suffix); break; } Push(ty); }
public void Visit(NodeInt i) { var token = i.Token; var suffix = token.NumericSuffix; TyRef ty; switch (suffix) { case "i8": ty = TyInt.Int8Ty; break; case "i16": ty = TyInt.Int16Ty; break; case "": case "i32": ty = TyInt.Int32Ty; break; case "i64": ty = TyInt.Int64Ty; break; case "u8": ty = TyUint.Uint8Ty; break; case "u16": ty = TyUint.Uint16Ty; break; case "u32": ty = TyUint.Uint32Ty; break; case "u64": ty = TyUint.Uint64Ty; break; default: ty = TyInt.Int32Ty; log.Error(i.Span, "Invalid integer suffix \"{0}\"!", suffix); break; } Push(i.Span, ty, ConstInt(TypeConverter.ToLLVMTy(ty.Raw, context), i.Token.IntegerValue, ty is TyUint)); }
public void Visit(NodeInt i) { }
public void Visit(NodeInt i) { Write("{0}{1}", i.Token.Image, i.Token.NumericSuffix); }
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); }