mirror of
https://github.com/Cekis/SWG-ScriptConverter.git
synced 2026-09-11 22:44:59 -04:00
24 lines
697 B
C#
24 lines
697 B
C#
using ScriptConverter.Ast.Expressions;
|
|
|
|
namespace ScriptConverter.Parser.Parselets.Expressions
|
|
{
|
|
class BinaryOperatorParselet : IInfixParselet
|
|
{
|
|
private readonly bool _isRight;
|
|
|
|
public BinaryOperatorParselet(PrecedenceValue precedence, bool isRight)
|
|
{
|
|
_isRight = isRight;
|
|
Precedence = (int)precedence;
|
|
}
|
|
|
|
public int Precedence { get; private set; }
|
|
|
|
public Expression Parse(ScriptParser parser, Expression left, ScriptToken token)
|
|
{
|
|
var right = parser.ParseExpression(Precedence - (_isRight ? 1 : 0));
|
|
return new BinaryOperatorExpression(token.Type, left, right);
|
|
}
|
|
}
|
|
}
|