// 11.9 Equality Operators private dynamic ParseEqualityExpression() { var firstToken = _extra.Tokens[_extra.Tokens.Count - 1]; var expr = ParseRelationalExpression(); while (Match("==") || Match("!=") || Match("===") || Match("!==")) { var op = Lex().Value; var r = ParseRelationalExpression(); var lastToken = _extra.Tokens[_extra.Tokens.Count - 1]; expr = new BinaryExpression(_codeGeneration) { Operator = op, Left = expr, Right = r, Range = new Range { Start = firstToken.Range.Start, End = lastToken.Range.End }, Loc = new Loc { Start = new Loc.Position { Line = firstToken.Loc.Start.Line, Column = firstToken.Loc.Start.Column }, End = new Loc.Position { Line = lastToken.Loc.End.Line, Column = lastToken.Loc.End.Column } } }; } return expr; }
private dynamic ParseBitwiseORExpression() { var firstToken = _extra.Tokens[_extra.Tokens.Count - 1]; var expr = ParseBitwiseXORExpression(); while (Match('|')) { Lex(); var r = ParseBitwiseXORExpression(); var lastToken = _extra.Tokens[_extra.Tokens.Count - 1]; expr = new BinaryExpression(_codeGeneration) { Operator = "|", Left = expr, Right = r, Range = new Range { Start = firstToken.Range.Start, End = lastToken.Range.End }, Loc = new Loc { Start = new Loc.Position { Line = firstToken.Loc.Start.Line, Column = firstToken.Loc.Start.Column }, End = new Loc.Position { Line = lastToken.Loc.End.Line, Column = lastToken.Loc.End.Column } } }; } return expr; }
// 11.8 Relational Operators private dynamic ParseRelationalExpression() { //var expr, previousAllowIn; var firstToken = _extra.Tokens[_extra.Tokens.Count - 1]; var previousAllowIn = _state.AllowIn; _state.AllowIn = true; var expr = ParseShiftExpression(); // PULAR ESPAĆOS! while (Match('<') || Match('>') || Match("<=") || Match(">=") || (previousAllowIn && MatchKeyword("in")) || MatchKeyword("instanceof")) { var op = Lex().Value; var r = ParseShiftExpression(); var lastToken = _extra.Tokens[_extra.Tokens.Count - 1]; expr = new BinaryExpression(_codeGeneration) { Operator = op, Left = expr, Right = r, Range = new Range { Start = firstToken.Range.Start, End = lastToken.Range.End }, Loc = new Loc { Start = new Loc.Position { Line = firstToken.Loc.Start.Line, Column = firstToken.Loc.Start.Column }, End = new Loc.Position { Line = lastToken.Loc.End.Line, Column = lastToken.Loc.End.Column } } }; } _state.AllowIn = previousAllowIn; return expr; }