Пример #1
0
 /// <summary>
 /// Create and initialize a new assignment expression.
 /// </summary>
 /// <param name="parent">Parent node that defines this expression.</param>
 /// <param name="identifier">Identifier token of the assignment target.</param>
 /// <param name="token">Token representing the assignment operator.</param>
 protected internal AssignmentNode(SemanticNode parent, IdentifierToken identifier, AssignmentOperatorToken token)
     : base(parent)
 {
     #if DEBUG
     if (identifier == null)
         throw new ArgumentNullException("identifier");
     if (token == null)
         throw new ArgumentNullException("token");
     #endif
     this.Target = new AssignmentTargetNode(this, identifier);
     this.AssignmentOperator = token;
 }
Пример #2
0
        protected virtual AssignmentNode ParseAssignment(SemanticNode parent, IdentifierToken identifier, AssignmentOperatorToken assignmentOperator)
        {
            // PARSE: <assignment> ::= <assignment target> assignmentOperator <expression>
            //      <assignment target> := identifier
            AssignmentNode result = new AssignmentNode(parent, identifier, assignmentOperator);

            Token token = this.GetNextTokenxx(Preference.NegativeSign);
            ExpressionNode expression = this.ParseExpression(result, token);

            if (expression == null)
                this.ReportParserError(result, SemanticErrors.MissingExpression, token);
            else
                result.SetContents(expression);

            return result;
        }