Skip to content
Snippets Groups Projects
Commit 9ba3b7d8 authored by Lior Spach's avatar Lior Spach
Browse files

Final adjusment

parent 4dc0ee36
No related branches found
No related tags found
No related merge requests found
......@@ -139,11 +139,9 @@ class Arith extends JavaTokenParsers {
case _ => println("Encontrei um procedimento em uma atribuição?"); "integer"
}
//assert tipos
if (tipoExpr!="integer" && tipoAtrib!="integer") {
if (tipoExpr != tipoAtrib) {
if (tipoExpr!="integer" && tipoAtrib!="integer" && tipoExpr!=tipoAtrib) {
println("Erro de tipo: Atribuição recebendo tipo diferente. (["+tipoAtrib+"] := ["+tipoExpr+"])")
sys.exit(1)
}
} //Otherwise ok!
}
......@@ -210,6 +208,7 @@ class Arith extends JavaTokenParsers {
stackbooltipo.clear()
}
else {
distinct.foreach{println}
println("Erro de tipo: dois lados da expressão booleana com tipos diferentes")
sys.exit(1)
}
......@@ -258,6 +257,7 @@ class Arith extends JavaTokenParsers {
def expr_simples:Parser[Object] = termo ~ rep( ("+"|"-") ~ termo ) ^^
{ e =>
stackbooltipo foreach println;
//TIPO
val distinct = stacktipo.distinct
if ( distinct.size == 1 || ( distinct.size == 2 && distinct.contains("integer") ) )
......@@ -268,11 +268,11 @@ class Arith extends JavaTokenParsers {
else { stacktipo.pop(); stackbooltipo.push( stacktipo.pop() ) }
else
stackbooltipo.push( stacktipo.top )
stacktipo.clear()
} else {
println("Erro de tipo detectado! Expresão com tipos diferentes")
println("Erro de tipo: Expresão com tipos diferentes")
sys.exit(1)
}
stacktipo.clear()
//END
e match {
case t ~ lst if ! lst.isEmpty =>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment