Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Student Reviews



More

Academic Training

Informative Articles

Find Jobs

We are Hiring!


All Courses

Choose a category

Loading...

All Courses

All Courses

logo

Mechanical

Uploaded on

05 Dec 2022

Common Problems In File Parsing Projects

logo

Skill-Lync

In this article, based on one of the student projects of Skill-Lync alumni, you will get a clear-cut idea of the common mistakes encountered during file parsing. But before that, let’s understand what file parsing is in brief.

What is File Parsing?

Parsing, syntax analysis, or syntactic analysis is the process of examining a string of symbols that adhere to formal grammar norms, whether in normal language, computer languages, or data structures. The word "parsing" is derived from the Latin word pars (orationis), which means "part (of speech).

In computer languages, parsing refers to the syntactic breakdown of the input code into its 

parts to make creating compilers and interpreters easier. It can be applied to separation or a split.

A file is parsed by reading in some kind of data stream and creating an in-memory model of its semantic content. This seeks to make it easier to change the data in some way.

of the common errors encountered while trying to solve the project.

Kinds of File Parsing

Essentially, the parser's job is to assess whether and how the input may be derived from the grammar's start symbol. There are essentially two ways to accomplish this:

Top-down parsing: It can be considered an effort to locate the input stream's left-most derivations by looking for parse trees using a top-down expansion of the provided formal grammar rules. Intake of tokens occurs left to right. By encompassing all possible right-hand sides of grammatical rules, the inclusive choice is utilised to deal with ambiguity. This is known as the primordial soup strategy. Primordial soup dissects the components of sentences like sentence diagramming. 

Bottom-up parsing: A parser might attempt to rewrite the input from the start symbol, starting with the input itself. The parser searches for the most fundamental items first, followed by elements that contain these, and so on. Examples of bottom-up parsers are LR parsers. Shift-Reduce parsing is another name for this kind of parser.

Common Problems During File Parsing

  • Inconsistency when comparing 2 arrays (element number inconsistency).

This error is encountered when students compare 2 arrays of the same data type with a different number of elements.

The code snippet below is to compare 2 string arrays elementwise and tells if each element is a match or mismatch.

The result of the code is as follows,

As you can see above, since the number of elements in the 2 arrays compared is different, the error is displayed as the program tries to compute for the 5th iteration where array A has no value.

  • Inconsistency when comparing 2 arrays (array type inconsistency).

A similar error can also occur when students try to compare 2 arrays with similar elements and dimensions, but the array type is different.

The example below is a program to compare 2 arrays with similar dimensions and elements but stored in different array types.

In Array A values from 1 to 5 are stored in a character array.

In Array B values from 1 to 5 are stored in a double array.

The result of the code is as follows,

As you can see clearly, despite the values stored in both arrays being the same when compared elementwise, all the comparison iterations fail and mismatch.

This is why comparisons should primarily be made between only similar data types.

Features of the String Compare function (strcmp)

The string compare function is a special function that has features that supersede the simple "if" function, Some of these capabilities are demonstrated below,

strcmp() can compare between cell and character datatypes

The code snippet below is used to compare between to arrays of type cell (B) and type character (A), Using the "if" command to directly compare between the 2 arrays will result in false clause.

But using the strcmp() let us observe the result.

The result of the code snippet above is below,

From the result above we can observe 2 things,

The result is positive irrespective of the inconsistency of the data type and array dimensions (i.e) Array A is of type character and has a length of 12 while Array B is of type cell and has a length of 1.

The cell array stores all the values are given in one string in one cell regardless of the data types.

Strcmp() cannot compare between character and double(numerical) data types

Despite strcmp() having superiority to the simple "if" statement, it still cannot compare between character and double data types.

The code snippet given below compares the same elements stored in 2 different array types (double vs character),

Array A is of datatype double.

Array B is of datatype character.

The result will be as displayed below,

From here, it is clear that regardless of the consistency between the two arrays with regard to elements and length the strcmp() still cannot compare a character and a double datatype.

The "while" command does not automatically update to the next line on every iteration when reading a file 

The "while", when used in reading a file, cannot automatically update to the next line, it needs to be explicitly mentioned to update and read a new file every time.


Author

author

Navin Baskar


Author

blogdetails

Skill-Lync

Subscribe to Our Free Newsletter

img

Continue Reading

Related Blogs

Shock tube simulation

Learn how to render a shock-tube-simulation and how to work on similar projects after enrolling into anyone of Skill-Lync's CAE courses.

Mechanical

10 May 2020


Design of Frontal BIW enclosure of a car (Bonnet)

In this blog, read how to design the frontal BIW enclosure of a car (Bonnet) and learn how Skill-Lync Master's Program in Automotive Design using CATIA V5 will help you get employed as a design engineer.

Mechanical

10 May 2020


What is Tetra Meshing?

Tetrahedral is a four- nodded solid element that can be generated through the tria element by creating a volume and also through the existing volume of the geometry. These elements are used where the geometry has high thickness and complexity. The image attached below is a representation of a Tetra element. The Tetra element will have 4 triangular faces with four nodes joining them together

Mechanical

02 Aug 2022


Realizing Connectors In HyperMesh

A connector is a mechanism that specifies how an object (vertex, edge, or face) is connected to another object or the ground. By often simulating the desired behaviour without having to build the precise shape or specify contact circumstances, connectors make modeling simpler.

Mechanical

03 Aug 2022


Mesh Sizing In Ansys Workbench

One of the most crucial processes in carrying out an accurate simulation using FEA is meshing. A mesh is composed of elements that have nodes—coordinate positions in space that might change depending on the element type—that symbolise the geometry's shape.

Mechanical

04 Aug 2022



Author

blogdetails

Skill-Lync

Subscribe to Our Free Newsletter

img

Continue Reading

Related Blogs

Shock tube simulation

Learn how to render a shock-tube-simulation and how to work on similar projects after enrolling into anyone of Skill-Lync's CAE courses.

Mechanical

10 May 2020


Design of Frontal BIW enclosure of a car (Bonnet)

In this blog, read how to design the frontal BIW enclosure of a car (Bonnet) and learn how Skill-Lync Master's Program in Automotive Design using CATIA V5 will help you get employed as a design engineer.

Mechanical

10 May 2020


What is Tetra Meshing?

Tetrahedral is a four- nodded solid element that can be generated through the tria element by creating a volume and also through the existing volume of the geometry. These elements are used where the geometry has high thickness and complexity. The image attached below is a representation of a Tetra element. The Tetra element will have 4 triangular faces with four nodes joining them together

Mechanical

02 Aug 2022


Realizing Connectors In HyperMesh

A connector is a mechanism that specifies how an object (vertex, edge, or face) is connected to another object or the ground. By often simulating the desired behaviour without having to build the precise shape or specify contact circumstances, connectors make modeling simpler.

Mechanical

03 Aug 2022


Mesh Sizing In Ansys Workbench

One of the most crucial processes in carrying out an accurate simulation using FEA is meshing. A mesh is composed of elements that have nodes—coordinate positions in space that might change depending on the element type—that symbolise the geometry's shape.

Mechanical

04 Aug 2022


Book a Free Demo, now!

Related Courses

https://d28ljev2bhqcfz.cloudfront.net/maincourse/thumb/introduction-hev-matlab-simulink_1612262875.jpg
Introduction to Hybrid Electric Vehicle using MATLAB and Simulink
4.8
23 Hours of content
Electrical Domain
Know more
https://d28ljev2bhqcfz.cloudfront.net/maincourse/thumb/vehicle-dynamics-matlab_1636606203.png
4.8
37 Hours of content
Cae Domain
Showing 1 of 4 courses