Ejemplo n.º 1
0
        public AphidParserException(AphidToken unexpectedToken, AphidTokenType expectedToken)
        {
            UnexpectedToken = unexpectedToken;
            ExpectedToken   = expectedToken;

            _message = string.Format(
                "{0}; expected {1}.",
                CreateUnexpectedMessage(unexpectedToken),
                expectedToken);
        }
Ejemplo n.º 2
0
        public bool Match(AphidTokenType tokenType)
        {
            if (CurrentToken.TokenType == tokenType)
            {
                NextToken();
                return(true);
            }

            throw new AphidParserException(CurrentToken, tokenType);
        }
        public AphidParserException(AphidToken unexpectedToken, AphidTokenType expectedToken)
        {
            UnexpectedToken = unexpectedToken;
            ExpectedToken = expectedToken;

            _message = string.Format(
                "{0}; expected {1}.",
                CreateUnexpectedMessage(unexpectedToken),
                expectedToken);
        }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 6
0
 private bool Match(AphidTokenType tokenType)
 {
     if (_currentToken.TokenType == tokenType)
     {
         NextToken();
         return(true);
     }
     else
     {
         throw new AphidParserException(_currentToken, tokenType);
     }
 }
Ejemplo n.º 7
0
 private bool Match(AphidTokenType tokenType)
 {
     if (_currentToken.TokenType == tokenType)
     {
         NextToken();
         return true;
     }
     else
     {
         throw new AphidParserException(_currentToken, tokenType);
     }
 }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
        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.
        }
Ejemplo n.º 11
0
        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.
        }
Ejemplo n.º 12
0
        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.
        }
Ejemplo n.º 13
0
        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;
 }
Ejemplo n.º 16
0
 public ControlFlowExpression(AphidTokenType type, Expression condition, List <Expression> body)
 {
     Type      = type;
     Condition = condition;
     Body      = body;
 }
Ejemplo n.º 17
0
 public AphidToken(AphidTokenType tokenType, string lexeme, int index)
 {
     TokenType = tokenType;
     Lexeme = lexeme;
     Index = index;
 }
Ejemplo n.º 18
0
 protected AphidToken Token(AphidTokenType type)
 {
     return Token(type, null);
 }
Ejemplo n.º 19
0
 protected override string GetUnaryPrefixOperator(AphidTokenType op) => !_unaryPrefixOperators.TryGetValue(op, out var value) ?
 base.GetUnaryPrefixOperator(op) :
 value;
Ejemplo n.º 20
0
 protected virtual string GetUnaryPostfixOperator(AphidTokenType op) =>
 GetOperator(_unaryPostfixOperators, op);
 public UnaryOperatorExpression(AphidTokenType op, Expression operand)
 {
     Operator = op;
     Operand  = operand;
 }
 public BinaryOperatorExpression(Expression left, AphidTokenType operatorType, Expression right)
 {
     LeftOperand  = left;
     Operator     = operatorType;
     RightOperand = right;
 }
 public ControlFlowExpression(AphidTokenType type, Expression condition, List<Expression> body)
 {
     Type = type;
     Condition = condition;
     Body = body;
 }
Ejemplo n.º 24
0
 public static AphidToken Token(AphidTokenType type, string lexeme) => new AphidToken(type, lexeme, 0);
Ejemplo n.º 25
0
 public UnaryOperatorExpression(AphidTokenType op, AphidExpression operand, bool isPostfix)
 {
     Operator = op;
     Operand = operand;
     IsPostfix = isPostfix;
 }
Ejemplo n.º 26
0
 public static AphidToken Token(AphidTokenType type) => Token(type, null);
Ejemplo n.º 27
0
 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;
        }
Ejemplo n.º 29
0
 protected virtual string GetBinaryOperator(AphidTokenType op) =>
 GetOperator(_binaryOperators, op);
Ejemplo n.º 30
0
 protected AphidToken Token(AphidTokenType type, string lexeme)
 {
     return(new AphidToken(type, lexeme, 0));
 }
Ejemplo n.º 31
0
 protected AphidToken Token(AphidTokenType type)
 {
     return(Token(type, null));
 }
Ejemplo n.º 32
0
 protected AphidToken Token(AphidTokenType type, string lexeme)
 {
     return new AphidToken(type, lexeme, 0);
 }