public override IAst Parse(Token raw) { var re = new ExpressionStmt(); if(raw.Raw.Contains("==")) { var x = Regex.Split(raw.Raw, "=="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "beq"; } else if (raw.Raw.Contains("!=")) { var x = Regex.Split(raw.Raw, "!="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Bne"; } else if (raw.Raw.Contains("<=")) { var x = Regex.Split(raw.Raw, "<="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Ble"; } else if (raw.Raw.Contains(">=")) { var x = Regex.Split(raw.Raw, ">="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Bge"; } else if (raw.Raw.Contains(">")) { var x = Regex.Split(raw.Raw, ">"); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Bgt"; } else if (raw.Raw.Contains("<")) { var x = Regex.Split(raw.Raw, "<"); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Blt"; } return re; }
public override IAst Parse(Token raw) { var re = new ExpressionStmt(); if (raw.Raw.Contains("==")) { var x = Regex.Split(raw.Raw, "=="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "beq"; } else if (raw.Raw.Contains("!=")) { var x = Regex.Split(raw.Raw, "!="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Bne"; } else if (raw.Raw.Contains("<=")) { var x = Regex.Split(raw.Raw, "<="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Ble"; } else if (raw.Raw.Contains(">=")) { var x = Regex.Split(raw.Raw, ">="); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Bge"; } else if (raw.Raw.Contains(">")) { var x = Regex.Split(raw.Raw, ">"); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Bgt"; } else if (raw.Raw.Contains("<")) { var x = Regex.Split(raw.Raw, "<"); re.Left = IAst.ParseToken(x[0].Trim())[0]; re.Right = IAst.ParseToken(x[1].Trim())[0]; re.Operator = "Blt"; } return(re); }