Semantic Errors (Syntax Parsing Engine) (2024)

Version

Is this content useful?

Thank you for your feedback!

Thank you for your feedback! You have rated this topic in the last 30 days.

Topic Overview

Required background

The following topics are prerequisites to understanding this topic:

TopicPurpose

The topics in this group explain the Infragistics Syntax Parsing Engine.

This topic provides an overview of the Syntax Parsing Engine’s Grammar.

The topics in this group explain the lexical analysis performed by the Syntax Parsing Engine.

This topic explains the syntax analysis performed by the Syntax Parsing Engine.

In this topic

This topic contains the following sections:

  • Semantic Errors

  • Overview

  • Example

  • Related Content

Semantic Errors

Overview

The Syntax Parsing Engine cannot recognize semantic errors. Finding these errors currently needs to be done by the developer after the syntax tree is constructed. Here are some examples of semantic errors:

Example

A semantic error is text which is grammatically correct but doesn’t make any sense. An example in the context of the C# language will be “int x = 12.3;” - 12.3 is not an integer literal and there is no implicit conversion from 12.3 to int, so this statement does not make sense. But it is grammatically correct. It conforms to the rules built into the C# grammar definition.

Here are some general cases of semantic errors in languages like C# and VB:

  • Type mismatches – There are a lot of ways to use the wrong type in C#. The example above is one way. Here are some other possible ways:

    • Passing the wrong type of value to a method.

    • Returning the wrong type of value from a method.

    • Setting the wrong type of value on a property.

    • Setting the wrong type of value on a field.

    • Setting the wrong type of value on a local variable.

    • Using a type in a generic argument list which doesn’t conform to the generic type constraints.

  • Arity mismatch – This means using the wrong number of arguments for something and there are many ways to do this as well:

    • Passing the wrong number of arguments to a method call.

    • Passing the wrong number of indexes to an array or indexer.

    • Using the wrong number of generic type arguments for a generic type or method.

  • Using undefined names – Using a namespace, type, method, field, variable, or property name which doesn’t exist.

  • Naming collisions – Here are some ways names can collide:

    • Defining two types in the same namespace with the same name

    • Defining two methods in the same class with the same argument list and name.

    • Defining a property, field, or nested type which has the same name as another property, field, or nested type in the same owning type.

    • Defining two local variables in the same or descendant scopes with the same names.

Related Content

Topics

The following topics provide additional information related to this topic.

TopicPurpose

This topic explains the lexical errors found by the Syntax Parsing Engine.

This topic explains the syntax errors found by the Syntax Parsing Engine.

The topics in this group explain the strategies used during the syntax analyzing of the document to identify syntax errors.

Semantic Errors (Syntax Parsing Engine) (2024)
Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6164

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.