public AphidParserException(AphidToken unexpectedToken, AphidTokenType expectedToken) { UnexpectedToken = unexpectedToken; ExpectedToken = expectedToken; _message = string.Format( "{0}; expected {1}.", CreateUnexpectedMessage(unexpectedToken), expectedToken); }
public bool Match(AphidTokenType tokenType) { if (CurrentToken.TokenType == tokenType) { NextToken(); return(true); } throw new AphidParserException(CurrentToken, tokenType); }
public TernaryOperatorExpression( AphidTokenType op, Expression firstOperand, Expression secondOperand, Expression thirdOperand) { Operator = op; FirstOperand = firstOperand; SecondOperand = secondOperand; ThirdOperand = thirdOperand; }
public TernaryOperatorExpression( AphidTokenType op, AphidExpression firstOperand, AphidExpression secondOperand, AphidExpression thirdOperand) { Operator = op; FirstOperand = firstOperand; SecondOperand = secondOperand; ThirdOperand = thirdOperand; }
private bool Match(AphidTokenType tokenType) { if (_currentToken.TokenType == tokenType) { NextToken(); return(true); } else { throw new AphidParserException(_currentToken, tokenType); } }
private bool Match(AphidTokenType tokenType) { if (_currentToken.TokenType == tokenType) { NextToken(); return true; } else { throw new AphidParserException(_currentToken, tokenType); } }
private Color GetColor(AphidTokenType tokenType) { switch (tokenType) { case AphidTokenType.breakKeyword: case AphidTokenType.catchKeyword: case AphidTokenType.defaultKeyword: case AphidTokenType.definedKeyword: case AphidTokenType.deleteKeyword: case AphidTokenType.elseKeyword: case AphidTokenType.extendKeyword: case AphidTokenType.falseKeyword: case AphidTokenType.finallyKeyword: case AphidTokenType.forKeyword: case AphidTokenType.ifKeyword: case AphidTokenType.inKeyword: case AphidTokenType.nullKeyword: case AphidTokenType.retKeyword: case AphidTokenType.switchKeyword: case AphidTokenType.thisKeyword: case AphidTokenType.trueKeyword: case AphidTokenType.tryKeyword: case AphidTokenType.whileKeyword: case AphidTokenType.functionOperator: case AphidTokenType.LoadLibraryOperator: case AphidTokenType.LoadScriptOperator: case AphidTokenType.PatternMatchingOperator: return(Colors.Blue); case AphidTokenType.String: case AphidTokenType.Number: case AphidTokenType.HexNumber: return(Colors.DarkRed); case AphidTokenType.Identifier: return(Colors.DarkOliveGreen); case AphidTokenType.Unknown: return(Colors.Red); default: return(Colors.Black); } }
public static ImplicitArgumentExpression Create( AphidExpressionContext context_aphidExpressionContext, AphidTokenType operator_w, int value_i, int value_i1 ) { ImplicitArgumentExpression implicitArgumentExpression = new ImplicitArgumentExpression(context_aphidExpressionContext, operator_w); ((AphidExpression)implicitArgumentExpression).Index = value_i; ((AphidExpression)implicitArgumentExpression).Length = value_i1; return(implicitArgumentExpression); // TODO: Edit factory method of ImplicitArgumentExpression // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
public static BinaryOperatorBodyExpression Create( AphidExpressionContext context_aphidExpressionContext, AphidTokenType operator_w, FunctionExpression function_functionExpression, int value_i, int value_i1 ) { BinaryOperatorBodyExpression binaryOperatorBodyExpression = new BinaryOperatorBodyExpression (context_aphidExpressionContext, operator_w, function_functionExpression); ((AphidExpression)binaryOperatorBodyExpression).Index = value_i; ((AphidExpression)binaryOperatorBodyExpression).Length = value_i1; return(binaryOperatorBodyExpression); // TODO: Edit factory method of BinaryOperatorBodyExpression // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
public static UnaryOperatorExpression Create( AphidExpressionContext context_aphidExpressionContext, AphidTokenType operator_w, AphidExpression operand_aphidExpression, bool isPostfix_b, int value_i, int value_i1 ) { UnaryOperatorExpression unaryOperatorExpression = new UnaryOperatorExpression(context_aphidExpressionContext, operator_w, operand_aphidExpression, isPostfix_b); ((AphidExpression)unaryOperatorExpression).Index = value_i; ((AphidExpression)unaryOperatorExpression).Length = value_i1; return(unaryOperatorExpression); // TODO: Edit factory method of UnaryOperatorExpression // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
public static TernaryOperatorExpression Create( AphidExpressionContext context_aphidExpressionContext, AphidTokenType operator_w, AphidExpression firstOperand_aphidExpression, AphidExpression secondOperand_aphidExpression1, AphidExpression thirdOperand_aphidExpression2, int value_i, int value_i1 ) { TernaryOperatorExpression ternaryOperatorExpression = new TernaryOperatorExpression(context_aphidExpressionContext, operator_w, firstOperand_aphidExpression, secondOperand_aphidExpression1, thirdOperand_aphidExpression2); ((AphidExpression)ternaryOperatorExpression).Index = value_i; ((AphidExpression)ternaryOperatorExpression).Length = value_i1; return(ternaryOperatorExpression); // TODO: Edit factory method of TernaryOperatorExpression // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
private Color GetColor(AphidTokenType tokenType) { switch (tokenType) { case AphidTokenType.breakKeyword: case AphidTokenType.catchKeyword: case AphidTokenType.defaultKeyword: case AphidTokenType.definedKeyword: case AphidTokenType.deleteKeyword: case AphidTokenType.elseKeyword: case AphidTokenType.extendKeyword: case AphidTokenType.falseKeyword: case AphidTokenType.finallyKeyword: case AphidTokenType.forKeyword: case AphidTokenType.ifKeyword: case AphidTokenType.inKeyword: case AphidTokenType.nullKeyword: case AphidTokenType.retKeyword: case AphidTokenType.switchKeyword: case AphidTokenType.thisKeyword: case AphidTokenType.trueKeyword: case AphidTokenType.tryKeyword: case AphidTokenType.whileKeyword: case AphidTokenType.functionOperator: case AphidTokenType.LoadLibraryOperator: case AphidTokenType.LoadScriptOperator: case AphidTokenType.PatternMatchingOperator: return Colors.Blue; case AphidTokenType.String: case AphidTokenType.Number: case AphidTokenType.HexNumber: return Colors.DarkRed; case AphidTokenType.Identifier: return Colors.DarkOliveGreen; case AphidTokenType.Unknown: return Colors.Red; default: return Colors.Black; } }
public BinaryOperatorExpression(Expression left, AphidTokenType operatorType, Expression right) { LeftOperand = left; Operator = operatorType; RightOperand = right; }
public UnaryOperatorExpression(AphidTokenType op, Expression operand) { Operator = op; Operand = operand; }
public ControlFlowExpression(AphidTokenType type, Expression condition, List <Expression> body) { Type = type; Condition = condition; Body = body; }
public AphidToken(AphidTokenType tokenType, string lexeme, int index) { TokenType = tokenType; Lexeme = lexeme; Index = index; }
protected AphidToken Token(AphidTokenType type) { return Token(type, null); }
protected override string GetUnaryPrefixOperator(AphidTokenType op) => !_unaryPrefixOperators.TryGetValue(op, out var value) ? base.GetUnaryPrefixOperator(op) : value;
protected virtual string GetUnaryPostfixOperator(AphidTokenType op) => GetOperator(_unaryPostfixOperators, op);
public ControlFlowExpression(AphidTokenType type, Expression condition, List<Expression> body) { Type = type; Condition = condition; Body = body; }
public static AphidToken Token(AphidTokenType type, string lexeme) => new AphidToken(type, lexeme, 0);
public UnaryOperatorExpression(AphidTokenType op, AphidExpression operand, bool isPostfix) { Operator = op; Operand = operand; IsPostfix = isPostfix; }
public static AphidToken Token(AphidTokenType type) => Token(type, null);
protected static string GetOperator(TokenMap table, AphidTokenType op) => !table.TryGetValue(op, out var s) ? throw new NotImplementedException() : s;
private AphidTokenType MutateOperator(AphidTokenType tokenType) { AphidTokenType mutatedType; if (!_opTable.TryGetValue(tokenType, out mutatedType)) { throw new InvalidOperationException(); } return mutatedType; }
protected virtual string GetBinaryOperator(AphidTokenType op) => GetOperator(_binaryOperators, op);
protected AphidToken Token(AphidTokenType type, string lexeme) { return(new AphidToken(type, lexeme, 0)); }
protected AphidToken Token(AphidTokenType type) { return(Token(type, null)); }
protected AphidToken Token(AphidTokenType type, string lexeme) { return new AphidToken(type, lexeme, 0); }