Skip to content
Extraits de code Groupes Projets
Vérifiée Valider f40462e0 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

PARSER: Add the token to operation conversion for expressions

parent 95959748
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!25Draft: New Vivy module spec
Pipeline #2823 en échec
......@@ -312,15 +312,49 @@ namespace Vivy::Script
IrELogicOp::OpType
IrELogicOp::getOpFromToken(Token tok)
{
if (tok.isSimple(TOKEN_AND))
return IrELogicOp::OpType::And;
else if (tok.isSimple(TOKEN_OR))
return IrELogicOp::OpType::Or;
// else if (tok.isSimple(TOKEN_XOR))
// return IrELogicOp::OpType::Xor;
else
throw std::runtime_error(tok.location().toString() + ": Not a LogicOp");
}
IrECompOp::OpType
IrECompOp::getOpFromToken(Token tok)
{
if (tok.isSimple(TOKEN_LE))
return IrECompOp::OpType::LE;
else if (tok.isSimple(TOKEN_LT))
return IrECompOp::OpType::LT;
else if (tok.isSimple(TOKEN_GE))
return IrECompOp::OpType::GE;
else if (tok.isSimple(TOKEN_GT))
return IrECompOp::OpType::GT;
else if (tok.isSimple(TOKEN_EQ))
return IrECompOp::OpType::EQ;
else if (tok.isSimple(TOKEN_NEQ))
return IrECompOp::OpType::NEQ;
else
throw std::runtime_error(tok.location().toString() + ": Not a CompOp");
}
IrEArithmeticOp::OpType
IrEArithmeticOp::getOpFromToken(Token tok)
{
if (tok.isSimple(TOKEN_PLUS))
return IrEArithmeticOp::OpType::Add;
else if (tok.isSimple(TOKEN_MINUS))
return IrEArithmeticOp::OpType::Sub;
else if (tok.isSimple(TOKEN_TIMES))
return IrEArithmeticOp::OpType::Mul;
else if (tok.isSimple(TOKEN_DIV))
return IrEArithmeticOp::OpType::Div;
else if (tok.isSimple(TOKEN_MOD))
return IrEArithmeticOp::OpType::Mod;
else
throw std::runtime_error(tok.location().toString() + ": Not a ArithmeticOp");
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter