Skip to content

Commit

Permalink
Fix verbosity boolean expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
quazi-irfan committed Oct 3, 2016
1 parent 5c20201 commit aeb18bc
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/OperandPkg/OperandUtility.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package OperandPkg;

import SymbolPkg.Node;
import SymbolPkg.SymbolTable;

import java.io.BufferedReader;
Expand Down Expand Up @@ -42,7 +41,7 @@ else if(expression.charAt(0) == '@'){
}

if(expression.length() >= 3 && expression.substring(expression.length()-2, expression.length()).equals(",X")){
if(operand.nbit & operand.ibit == false){
if(operand.nbit & !operand.ibit){
System.out.println("@ or # can't be mixed with ,X");
return;
}
Expand All @@ -61,18 +60,16 @@ else if(expression.charAt(0) == '@'){

private static void validateExp(String expression, Operand operand, SymbolTable symbolTable){
if(expression.indexOf('+') >= 0 || expression.indexOf('-') >= 0){
int token1Value =0, token2Value=0;
boolean token1rflag=false, token2rflag=false;

StringTokenizer tokenizer = new StringTokenizer(expression, "+-");

String temp = tokenizer.nextToken();
token1Value = Token.getTokenValue(temp, symbolTable);
token1rflag = Token.getTokenRflag(temp, symbolTable);
int token1Value = Token.getTokenValue(temp, symbolTable);
boolean token1rflag = Token.getTokenRflag(temp, symbolTable);

temp = tokenizer.nextToken();
token2Value = Token.getTokenValue(temp, symbolTable);
token2rflag = Token.getTokenRflag(temp, symbolTable);
int token2Value = Token.getTokenValue(temp, symbolTable);
boolean token2rflag = Token.getTokenRflag(temp, symbolTable);

// set operands value, and flag
if(expression.indexOf('+') >= 0)
Expand Down Expand Up @@ -101,22 +98,22 @@ public static void print(Operand operand){

private static String evaluateRelocability(boolean token1rflag, boolean token2rflag, String expression){
if(expression.indexOf('+') >= 0){
if(token1rflag == false & token2rflag == false)
if(!token1rflag & !token2rflag)
return "false";
if(token1rflag == false & token2rflag == true)
if(!token1rflag & token2rflag)
return "true";
if(token1rflag == true & token2rflag == false)
if(token1rflag & !token2rflag)
return "true";
if(token1rflag == true & token2rflag == true)
if(token1rflag & token2rflag)
return "error";
} else if(expression.indexOf('-') >= 0){
if(token1rflag == false & token2rflag == false)
if(!token1rflag& !token2rflag)
return "false";
if(token1rflag == false & token2rflag == true)
if(!token1rflag & !token2rflag)
return "error";
if(token1rflag == true & token2rflag == false)
if(token1rflag & !token2rflag)
return "true";
if(token1rflag == true & token2rflag == true)
if(token1rflag & token2rflag)
return "false";
}

Expand Down

0 comments on commit aeb18bc

Please sign in to comment.