public override void Check() { exp.Check(); if (exp.type != 'b') { throw new ArgumentException($" Semantic error at line {line}: If argument has to be of type bool."); } }
public override void Check() { Compiler.loopDepth++; exp.Check(); if (exp.type != 'b') { throw new ArgumentException($" Semantic error at line {line}: While argument has to be of type bool."); } }
public override void Check() { left.Check(); right.Check(); if (left.type != 'i' || right.type != 'i') { throw new ArgumentException($" Semantic error at line {line}: For bit operations both arguments have to be of type int."); } type = 'i'; }
public override void Check() { left.Check(); right.Check(); if (left.type == 'b' || right.type == 'b') { throw new ArgumentException($" Semantic error at line {line}: Bool is not a proper type for additive and multiplivative operations."); } type = left.type == 'i' && right.type == 'i' ? 'i' : 'd'; }
public override void Check() { left.Check(); right.Check(); if ((left.type == 'b') ^ (right.type == 'b')) { throw new ArgumentException($" Semantic error at line {line}: For relational operations both arguments or none of them have to be of type bool."); } if (left.type == 'b' && (kind != Tokens.Equal && kind != Tokens.NotEqual)) { throw new ArgumentException($" Semantic error at line {line}: The only accepted comparisons between two bools are == and !=."); } type = 'b'; }
public override void Check() { exp.Check(); if (kind == Tokens.Minus) { if (exp.type == 'b') { throw new ArgumentException($" Semantic error at line {line}: Unary minus does not accept arguments of type bool."); } type = exp.type; } else if (kind == Tokens.BitNeg) { if (exp.type != 'i') { throw new ArgumentException($" Semantic error at line {line}: Bitwise negation accepts only arguments of type int."); } type = exp.type; } else if (kind == Tokens.Neg) { if (exp.type != 'b') { throw new ArgumentException($" Semantic error at line {line}: Logical negation accepts only arguments of type bool."); } type = exp.type; } else if (kind == Tokens.IntCast) { type = 'i'; } else if (kind == Tokens.DoubleCast) { type = 'd'; } }
public override void Check() { if (!Compiler.symbols.Any(x => x.ident == ident)) { throw new ArgumentException($" Semantic error at line {line}: {ident} undeclared."); } var originalSymbol = Compiler.symbols.First(x => x.ident == ident); type = originalSymbol.type; generatedName = originalSymbol.generatedName; exp.Check(); if (type != exp.type) { if (type != 'd' || exp.type != 'i') { throw new ArgumentException($" Semantic error at line {line}: Cannot assign expression type to ident type."); } } }
public override void Check() { exp.Check(); }